Skip to content

Instantly share code, notes, and snippets.

@b2l

b2l/todo.js Secret

Last active August 29, 2015 14:05
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 b2l/9b391b0e048f529fbfba to your computer and use it in GitHub Desktop.
Save b2l/9b391b0e048f529fbfba to your computer and use it in GitHub Desktop.
// --- 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