backbone-generator/templates/collection_spec.js.erb

22 lines
539 B
Plaintext
Raw Normal View History

2011-04-15 19:02:36 +00:00
describe('<%= object_name %>sCollection', function() {
2011-04-15 18:55:37 +00:00
var collection, server;
beforeEach(function() {
server = sinon.fakeServer().create();
});
afterEach(function() {
server.restore();
});
it('should fetch records from the API', function() {
2011-04-15 19:02:36 +00:00
collection = new <%= object_name %>sCollection();
2011-04-15 18:55:37 +00:00
server.respondWith('GET', '<%= underscore_name %>', [ 200, { 'Content-type': 'application/json' }, "[{id: 1}]" ]);
collection.fetch()
server.respond();
expect(collection.length).toEqual(1);
});
2011-04-15 19:02:36 +00:00
}s);