Add an additional test case related to re-fetching data.
This commit is contained in:
@@ -83,6 +83,7 @@ define(['sinon', 'underscore', 'URI'], function(sinon, _, URI) {
|
||||
requestIndex = requests.length - 1;
|
||||
}
|
||||
request = requests[requestIndex];
|
||||
expect(new URI(request.url).path()).toEqual(expectedUrl);
|
||||
parameters = new URI(request.url).query(true);
|
||||
delete parameters._; // Ignore the cache-busting argument
|
||||
expect(parameters).toEqual(expectedParameters);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
;(function (define) {
|
||||
'use strict';
|
||||
define(['teams/js/collections/base', 'teams/js/models/topic', 'gettext'],
|
||||
function(BaseCollection, TopicModel, gettext) {
|
||||
define(['teams/js/collections/base', 'teams/js/models/topic', 'gettext', 'underscore'],
|
||||
function(BaseCollection, TopicModel, gettext, _) {
|
||||
var TopicCollection = BaseCollection.extend({
|
||||
initialize: function(topics, options) {
|
||||
var self = this;
|
||||
|
||||
@@ -7,7 +7,6 @@ define(['backbone', 'URI', 'underscore', 'common/js/spec_helpers/ajax_helpers',
|
||||
topicCollection = new TopicCollection(
|
||||
{
|
||||
"count": 6,
|
||||
"num_pages": 2,
|
||||
"current_page": 1,
|
||||
"start": 0,
|
||||
"results": [
|
||||
|
||||
@@ -64,7 +64,7 @@ define([
|
||||
myTeamsView.render();
|
||||
AjaxHelpers.expectJsonRequestURL(
|
||||
requests,
|
||||
'foo',
|
||||
'api/teams/team_memberships',
|
||||
{
|
||||
expand : 'team',
|
||||
username : 'testUser',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define([
|
||||
'backbone', 'teams/js/collections/topic', 'teams/js/views/topics',
|
||||
'teams/js/spec_helpers/team_spec_helpers'
|
||||
], function (Backbone, TopicCollection, TopicsView, TeamSpecHelpers) {
|
||||
'backbone', 'underscore', 'teams/js/collections/topic', 'teams/js/views/topics',
|
||||
'teams/js/spec_helpers/team_spec_helpers', 'common/js/spec_helpers/ajax_helpers'
|
||||
], function (Backbone, _, TopicCollection, TopicsView, TeamSpecHelpers, AjaxHelpers) {
|
||||
'use strict';
|
||||
describe('TopicsView', function () {
|
||||
var initialTopics, topicCollection, createTopicsView,
|
||||
@@ -33,12 +33,14 @@ define([
|
||||
"num_pages": 2,
|
||||
"current_page": 1,
|
||||
"start": 0,
|
||||
"results": initialTopics
|
||||
"results": initialTopics,
|
||||
"sort_order": "name"
|
||||
},
|
||||
{
|
||||
teamEvents: TeamSpecHelpers.teamEvents,
|
||||
course_id: 'my/course/id',
|
||||
parse: true
|
||||
parse: true,
|
||||
url: 'api/teams/topics'
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -57,5 +59,23 @@ define([
|
||||
expect(footerEl.text()).toMatch('1\\s+out of\\s+\/\\s+2');
|
||||
expect(footerEl).not.toHaveClass('hidden');
|
||||
});
|
||||
|
||||
it('refreshes the topics when a team is created', function() {
|
||||
var requests = AjaxHelpers.requests(this),
|
||||
topicsView = createTopicsView();
|
||||
|
||||
topicsView.collection.teamEvents.trigger('teams:update', { action: 'create' });
|
||||
topicsView.render();
|
||||
AjaxHelpers.expectJsonRequestURL(
|
||||
requests,
|
||||
'api/teams/topics',
|
||||
{
|
||||
course_id : 'my/course/id',
|
||||
page : '1',
|
||||
page_size : '5', // currently the page size is determined by the size of the collection
|
||||
order_by : 'name'
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user