backbone-generator/templates/collection_spec.js.erb

22 lines
539 B
Plaintext

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