Skip to content

Instantly share code, notes, and snippets.

@giovanettid
Created February 23, 2016 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giovanettid/d3b9e7bbee935bff9635 to your computer and use it in GitHub Desktop.
Save giovanettid/d3b9e7bbee935bff9635 to your computer and use it in GitHub Desktop.
describe('Todos', function() {
var Todo = requirejs('models/todo');
var todos = requirejs('collections/todos');
beforeEach(function() {
todos.reset();
});
it('filtering completed', function() {
todos.set([{title: 'todo1', completed: true}, {title: 'todo2', completed: false}, {completed: true}]);
var todosCompleted = todos.completed();
expect(todosCompleted).to.have.length(2);
expect(todosCompleted[0].get('completed')).to.be.true;
expect(todosCompleted[1].get('completed')).to.be.true;
});
it('filtering remaining', function() {
var todo1 = new Todo();
todo1.toggle();
var todo2 = new Todo();
todos.set([todo1, todo2]);
var todosRemaining = todos.remaining();
expect(todosRemaining).to.have.length(1);
expect(todosRemaining[0]).to.eql(todo2);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment