-
-
Save b2l/9b391b0e048f529fbfba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// --- Dependencies | |
var Todos = require('../js/Todos'); // Checkout the js/Todos.js file for how to do this | |
var expect = require('chai').expect; // Get the expect DSL from chai | |
// Init a test suite | |
describe('Todos', function() { | |
// A test case | |
it('should create a new todo with name and default value', function() { | |
// given | |
var name = 'a new todo'; | |
// when | |
var todo = Todos.createTodo(name); | |
// then | |
expect(todo).to.have.property('name').equal(name); | |
expect(todo).to.have.property('done').equal(false); | |
}); | |
it('should retrieve all todos', function() { | |
var todos = Todos.getAll(); | |
expect(todos).to.have.property('length').equal(1); | |
expect(todos[0]).to.have.property('name').equal('a new todo'); | |
expect(todos[0]).to.have.property('done').equal(false); | |
}); | |
/* --- All other test case here | |
* See https://github.com/b2l/todo-app/blob/master/tests/todo-model.js for the complete file | |
*/ | |
it('should mark a todo as not done', function() { | |
var todos = Todos.getAll(); | |
var todo = todos[0]; | |
todo.markAsNotDone(); | |
var todos = Todos.getAll(); | |
expect(todos).to.have.property('length').equal(1); | |
expect(todos[0]).to.have.property('done').equal(false); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment