Commit c929cdb5 by cahrens

Add an additional test case related to re-fetching data.

parent 1d01da07
...@@ -83,6 +83,7 @@ define(['sinon', 'underscore', 'URI'], function(sinon, _, URI) { ...@@ -83,6 +83,7 @@ define(['sinon', 'underscore', 'URI'], function(sinon, _, URI) {
requestIndex = requests.length - 1; requestIndex = requests.length - 1;
} }
request = requests[requestIndex]; request = requests[requestIndex];
expect(new URI(request.url).path()).toEqual(expectedUrl);
parameters = new URI(request.url).query(true); parameters = new URI(request.url).query(true);
delete parameters._; // Ignore the cache-busting argument delete parameters._; // Ignore the cache-busting argument
expect(parameters).toEqual(expectedParameters); expect(parameters).toEqual(expectedParameters);
......
;(function (define) { ;(function (define) {
'use strict'; 'use strict';
define(['teams/js/collections/base', 'teams/js/models/topic', 'gettext'], define(['teams/js/collections/base', 'teams/js/models/topic', 'gettext', 'underscore'],
function(BaseCollection, TopicModel, gettext) { function(BaseCollection, TopicModel, gettext, _) {
var TopicCollection = BaseCollection.extend({ var TopicCollection = BaseCollection.extend({
initialize: function(topics, options) { initialize: function(topics, options) {
var self = this; var self = this;
......
...@@ -7,7 +7,6 @@ define(['backbone', 'URI', 'underscore', 'common/js/spec_helpers/ajax_helpers', ...@@ -7,7 +7,6 @@ define(['backbone', 'URI', 'underscore', 'common/js/spec_helpers/ajax_helpers',
topicCollection = new TopicCollection( topicCollection = new TopicCollection(
{ {
"count": 6, "count": 6,
"num_pages": 2,
"current_page": 1, "current_page": 1,
"start": 0, "start": 0,
"results": [ "results": [
......
...@@ -64,7 +64,7 @@ define([ ...@@ -64,7 +64,7 @@ define([
myTeamsView.render(); myTeamsView.render();
AjaxHelpers.expectJsonRequestURL( AjaxHelpers.expectJsonRequestURL(
requests, requests,
'foo', 'api/teams/team_memberships',
{ {
expand : 'team', expand : 'team',
username : 'testUser', username : 'testUser',
......
define([ define([
'backbone', 'teams/js/collections/topic', 'teams/js/views/topics', 'backbone', 'underscore', 'teams/js/collections/topic', 'teams/js/views/topics',
'teams/js/spec_helpers/team_spec_helpers' 'teams/js/spec_helpers/team_spec_helpers', 'common/js/spec_helpers/ajax_helpers'
], function (Backbone, TopicCollection, TopicsView, TeamSpecHelpers) { ], function (Backbone, _, TopicCollection, TopicsView, TeamSpecHelpers, AjaxHelpers) {
'use strict'; 'use strict';
describe('TopicsView', function () { describe('TopicsView', function () {
var initialTopics, topicCollection, createTopicsView, var initialTopics, topicCollection, createTopicsView,
...@@ -33,12 +33,14 @@ define([ ...@@ -33,12 +33,14 @@ define([
"num_pages": 2, "num_pages": 2,
"current_page": 1, "current_page": 1,
"start": 0, "start": 0,
"results": initialTopics "results": initialTopics,
"sort_order": "name"
}, },
{ {
teamEvents: TeamSpecHelpers.teamEvents, teamEvents: TeamSpecHelpers.teamEvents,
course_id: 'my/course/id', course_id: 'my/course/id',
parse: true parse: true,
url: 'api/teams/topics'
} }
); );
}); });
...@@ -57,5 +59,23 @@ define([ ...@@ -57,5 +59,23 @@ define([
expect(footerEl.text()).toMatch('1\\s+out of\\s+\/\\s+2'); expect(footerEl.text()).toMatch('1\\s+out of\\s+\/\\s+2');
expect(footerEl).not.toHaveClass('hidden'); 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'
}
);
});
}); });
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment