backbone-generator/templates/collection_spec.js.erb

22 lines
519 B
Plaintext

describe('<%= object_name %>s', 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 %>s();
server.respondWith('GET', '<%= underscore_name %>', [ 200, { 'Content-type': 'application/json' }, "[{id: 1}]" ]);
collection.fetch()
server.respond();
expect(collection.length).toEqual(1);
});
}s);