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
d09034e0
Commit
d09034e0
authored
Sep 23, 2015
by
Andy Armstrong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve team testing of routers
parent
d8d49f75
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
62 additions
and
28 deletions
+62
-28
common/static/common/js/spec_helpers/page_helpers.js
+47
-16
lms/djangoapps/teams/static/teams/js/spec/teams_tab_factory_spec.js
+3
-7
lms/djangoapps/teams/static/teams/js/spec/views/edit_team_spec.js
+3
-1
lms/djangoapps/teams/static/teams/js/spec/views/instructor_tools_spec.js
+4
-2
lms/djangoapps/teams/static/teams/js/spec/views/teams_tab_spec.js
+0
-0
lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js
+5
-2
lms/static/js/spec/search/search_spec.js
+0
-0
No files found.
common/static/common/js/spec_helpers/page_helpers.js
View file @
d09034e0
define
([
// jshint ignore:line
],
function
()
{
'use strict'
;
var
getLocationHash
;
/**
* Helper method that returns url hash.
* @return {String} Returns anchor part of current url.
*/
getLocationHash
=
function
()
{
return
window
.
location
.
hash
;
};
define
([
"backbone"
],
function
(
Backbone
)
{
'use strict'
;
var
getLocationHash
,
preventBackboneChangingUrl
;
return
{
'getLocationHash'
:
getLocationHash
};
/**
* Helper method that returns url hash.
* @return {String} Returns anchor part of current url.
*/
getLocationHash
=
function
()
{
return
window
.
location
.
hash
;
};
});
/**
* Prevent Backbone tests from changing the browser's URL.
*
* This function modifies Backbone so that tests can navigate
* without modifying the browser's URL. It works be adding
* stub versions of Backbone's hash functions so that updating
* the hash doesn't change the URL but instead updates a
* local object. The router's callbacks are still invoked
* so that to the test it appears that navigation is behaving
* as expected.
*
* Note: it is important that tests don't update the browser's
* URL because subsequent tests could find themselves in an
* unexpected navigation state.
*/
preventBackboneChangingUrl
=
function
()
{
var
history
=
{
currentFragment
:
''
};
// Stub out the Backbone router so that the browser doesn't actually navigate
spyOn
(
Backbone
.
history
,
'_updateHash'
).
andCallFake
(
function
(
location
,
fragment
,
replace
)
{
history
.
currentFragment
=
fragment
;
});
// Stub out getHash so that Backbone thinks that the browser has navigated
spyOn
(
Backbone
.
history
,
'getHash'
).
andCallFake
(
function
()
{
return
history
.
currentFragment
;
});
};
return
{
'getLocationHash'
:
getLocationHash
,
'preventBackboneChangingUrl'
:
preventBackboneChangingUrl
};
});
lms/djangoapps/teams/static/teams/js/spec/teams_tab_factory_spec.js
View file @
d09034e0
define
([
'jquery'
,
'backbone'
,
'teams/js/teams_tab_factory'
,
'teams/js/spec_helpers/team_spec_helpers'
],
function
(
$
,
Backbone
,
TeamsTabFactory
,
TeamSpecHelpers
)
{
'
common/js/spec_helpers/page_helpers'
,
'
teams/js/spec_helpers/team_spec_helpers'
],
function
(
$
,
Backbone
,
TeamsTabFactory
,
PageHelpers
,
TeamSpecHelpers
)
{
'use strict'
;
describe
(
"Teams Tab Factory"
,
function
()
{
...
...
@@ -10,6 +10,7 @@ define(['jquery', 'backbone', 'teams/js/teams_tab_factory',
beforeEach
(
function
()
{
setFixtures
(
'<section class="teams-content"></section>'
);
PageHelpers
.
preventBackboneChangingUrl
();
});
afterEach
(
function
()
{
...
...
@@ -17,11 +18,6 @@ define(['jquery', 'backbone', 'teams/js/teams_tab_factory',
});
it
(
'can render the "Teams" tab'
,
function
()
{
// Hack to make sure the URL fragments from earlier
// tests don't interfere with Backbone routing by the
// teams tab view
document
.
location
.
hash
=
''
;
initializeTeamsTabFactory
();
expect
(
$
(
'.teams-content'
).
text
()).
toContain
(
'See all teams in your course, organized by topic'
);
});
...
...
lms/djangoapps/teams/static/teams/js/spec/views/edit_team_spec.js
View file @
d09034e0
...
...
@@ -3,10 +3,11 @@ define([
'underscore'
,
'backbone'
,
'common/js/spec_helpers/ajax_helpers'
,
'common/js/spec_helpers/page_helpers'
,
'teams/js/views/edit_team'
,
'teams/js/models/team'
,
'teams/js/spec_helpers/team_spec_helpers'
],
function
(
$
,
_
,
Backbone
,
AjaxHelpers
,
TeamEditView
,
TeamModel
,
TeamSpecHelpers
)
{
],
function
(
$
,
_
,
Backbone
,
AjaxHelpers
,
PageHelpers
,
TeamEditView
,
TeamModel
,
TeamSpecHelpers
)
{
'use strict'
;
describe
(
'CreateEditTeam'
,
function
()
{
...
...
@@ -90,6 +91,7 @@ define([
beforeEach
(
function
()
{
setFixtures
(
'<div class="teams-content"></div>'
);
PageHelpers
.
preventBackboneChangingUrl
();
spyOn
(
Backbone
.
history
,
'navigate'
);
});
...
...
lms/djangoapps/teams/static/teams/js/spec/views/instructor_tools_spec.js
View file @
d09034e0
...
...
@@ -6,8 +6,9 @@ define([
'teams/js/views/instructor_tools'
,
'teams/js/views/team_utils'
,
'teams/js/spec_helpers/team_spec_helpers'
,
'common/js/spec_helpers/ajax_helpers'
],
function
(
$
,
Backbone
,
_
,
Team
,
InstructorToolsView
,
TeamUtils
,
TeamSpecHelpers
,
AjaxHelpers
)
{
'common/js/spec_helpers/ajax_helpers'
,
'common/js/spec_helpers/page_helpers'
],
function
(
$
,
Backbone
,
_
,
Team
,
InstructorToolsView
,
TeamUtils
,
TeamSpecHelpers
,
AjaxHelpers
,
PageHelpers
)
{
'use strict'
;
describe
(
'Instructor Tools'
,
function
()
{
...
...
@@ -37,6 +38,7 @@ define([
beforeEach
(
function
()
{
setFixtures
(
'<div id="page-prompt"></div>'
);
PageHelpers
.
preventBackboneChangingUrl
();
spyOn
(
Backbone
.
history
,
'navigate'
);
spyOn
(
TeamUtils
,
'showMessage'
);
view
=
createInstructorTools
().
render
();
...
...
lms/djangoapps/teams/static/teams/js/spec/views/teams_tab_spec.js
View file @
d09034e0
This diff is collapsed.
Click to expand it.
lms/djangoapps/teams/static/teams/js/spec/views/topic_teams_spec.js
View file @
d09034e0
...
...
@@ -4,8 +4,10 @@ define([
'teams/js/collections/team_membership'
,
'teams/js/views/topic_teams'
,
'teams/js/spec_helpers/team_spec_helpers'
,
'common/js/spec_helpers/ajax_helpers'
],
function
(
Backbone
,
TeamCollection
,
TeamMembershipCollection
,
TopicTeamsView
,
TeamSpecHelpers
,
AjaxHelpers
)
{
'common/js/spec_helpers/ajax_helpers'
,
'common/js/spec_helpers/page_helpers'
],
function
(
Backbone
,
TeamCollection
,
TeamMembershipCollection
,
TopicTeamsView
,
TeamSpecHelpers
,
AjaxHelpers
,
PageHelpers
)
{
'use strict'
;
describe
(
'Topic Teams View'
,
function
()
{
var
createTopicTeamsView
=
function
(
options
)
{
...
...
@@ -39,6 +41,7 @@ define([
beforeEach
(
function
()
{
setFixtures
(
'<div class="teams-container"></div>'
);
PageHelpers
.
preventBackboneChangingUrl
();
});
it
(
'can render itself'
,
function
()
{
...
...
lms/static/js/spec/search/search_spec.js
View file @
d09034e0
This diff is collapsed.
Click to expand it.
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