Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
2dc5b8e8
Commit
2dc5b8e8
authored
Sep 24, 2015
by
Christine Lytwynec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make verifyElementInFocus a ViewHelpers method
parent
f96d4b71
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
24 deletions
+27
-24
common/static/common/js/spec/components/feedback_spec.js
+6
-22
common/static/common/js/spec_helpers/view_helpers.js
+21
-2
No files found.
common/static/common/js/spec/components/feedback_spec.js
View file @
2dc5b8e8
// Generated by CoffeeScript 1.6.1
(
function
()
{
define
([
"jquery"
,
"common/js/components/views/feedback"
,
"common/js/components/views/feedback_notification"
,
"common/js/components/views/feedback_alert"
,
"common/js/components/views/feedback_prompt"
,
"sinon"
,
"jquery.simulate"
],
function
(
$
,
SystemFeedback
,
NotificationView
,
AlertView
,
PromptView
,
sinon
)
{
define
([
"jquery"
,
"common/js/components/views/feedback"
,
"common/js/components/views/feedback_notification"
,
"common/js/components/views/feedback_alert"
,
"common/js/components/views/feedback_prompt"
,
'common/js/spec_helpers/view_helpers'
,
"sinon"
,
"jquery.simulate"
],
function
(
$
,
SystemFeedback
,
NotificationView
,
AlertView
,
PromptView
,
ViewHelpers
,
sinon
)
{
var
tpl
;
tpl
=
readFixtures
(
'system-feedback.underscore'
);
beforeEach
(
function
()
{
...
...
@@ -137,21 +137,13 @@
var
view
;
view
=
new
PromptView
.
Confirmation
(
this
.
options
).
show
();
expect
(
this
.
inFocusSpy
).
toHaveBeenCalled
();
return
waitsFor
(
function
()
{
return
view
.
$
(
'.wrapper-prompt:focus'
).
length
===
1
;
},
"The modal should have focus"
,
500
);
return
ViewHelpers
.
verifyElementInFocus
(
view
,
".wrapper-prompt"
)
});
it
(
"is not focused on hide"
,
function
()
{
var
view
;
view
=
new
PromptView
.
Confirmation
(
this
.
options
).
hide
();
expect
(
this
.
outFocusSpy
).
toHaveBeenCalled
();
return
waitsFor
(
function
()
{
return
view
.
$
(
'.wrapper-prompt:focus'
).
length
===
0
;
},
"The modal should not have focus"
,
500
);
return
ViewHelpers
.
verifyElementNotInFocus
(
view
,
".wrapper-prompt"
)
});
it
(
"traps keyboard focus when moving forward"
,
function
()
{
var
view
;
...
...
@@ -161,11 +153,7 @@
"keydown"
,
{
keyCode
:
$
.
simulate
.
keyCode
.
TAB
}
);
return
waitsFor
(
function
()
{
return
view
.
$
(
'.action-primary:focus'
).
length
===
1
;
},
"The first action button should have focus"
,
500
);
return
ViewHelpers
.
verifyElementInFocus
(
view
,
".action-primary"
)
});
it
(
"traps keyboard focus when moving backward"
,
function
()
{
var
view
;
...
...
@@ -175,11 +163,7 @@
"keydown"
,
{
keyCode
:
$
.
simulate
.
keyCode
.
TAB
,
shiftKey
:
true
}
);
return
waitsFor
(
function
()
{
return
view
.
$
(
'.action-secondary:focus'
).
length
===
1
;
},
"The last action button should have focus"
,
500
);
return
ViewHelpers
.
verifyElementInFocus
(
view
,
".action-secondary"
)
});
return
it
(
"changes class on body"
,
function
()
{
var
view
;
...
...
common/static/common/js/spec_helpers/view_helpers.js
View file @
2dc5b8e8
...
...
@@ -10,7 +10,8 @@ define(["jquery", "common/js/components/views/feedback_notification", "common/js
verifyFeedbackHidden
,
createNotificationSpy
,
verifyNotificationShowing
,
verifyNotificationHidden
,
createPromptSpy
,
confirmPrompt
,
inlineEdit
,
verifyInlineEditChange
,
installMockAnalytics
,
removeMockAnalytics
,
verifyPromptShowing
,
verifyPromptHidden
,
clickDeleteItem
,
patchAndVerifyRequest
,
submitAndVerifyFormSuccess
,
submitAndVerifyFormError
;
clickDeleteItem
,
patchAndVerifyRequest
,
submitAndVerifyFormSuccess
,
submitAndVerifyFormError
,
verifyElementInFocus
,
verifyElementNotInFocus
;
installViewTemplates
=
function
()
{
appendSetFixtures
(
'<div id="page-notification"></div>'
);
...
...
@@ -127,6 +128,22 @@ define(["jquery", "common/js/components/views/feedback_notification", "common/js
verifyNotificationShowing
(
notificationSpy
,
/Saving/
);
};
verifyElementInFocus
=
function
(
view
,
selector
)
{
waitsFor
(
function
()
{
return
view
.
$
(
selector
+
':focus'
).
length
===
1
;
},
"element to have focus: "
+
selector
,
500
);
};
verifyElementNotInFocus
=
function
(
view
,
selector
)
{
waitsFor
(
function
()
{
return
view
.
$
(
selector
+
':focus'
).
length
===
0
;
},
"element to not have focus: "
+
selector
,
500
);
};
return
{
'installViewTemplates'
:
installViewTemplates
,
'createNotificationSpy'
:
createNotificationSpy
,
...
...
@@ -143,7 +160,9 @@ define(["jquery", "common/js/components/views/feedback_notification", "common/js
'clickDeleteItem'
:
clickDeleteItem
,
'patchAndVerifyRequest'
:
patchAndVerifyRequest
,
'submitAndVerifyFormSuccess'
:
submitAndVerifyFormSuccess
,
'submitAndVerifyFormError'
:
submitAndVerifyFormError
'submitAndVerifyFormError'
:
submitAndVerifyFormError
,
'verifyElementInFocus'
:
verifyElementInFocus
,
'verifyElementNotInFocus'
:
verifyElementNotInFocus
};
});
}).
call
(
this
,
define
||
RequireJS
.
define
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment