Created
April 23, 2012 11:16
-
-
Save stas/2470276 to your computer and use it in GitHub Desktop.
An attempt to implement todomvc specs
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
describe('Todos Specifications', function() { | |
var title = 'Be awesome!'; | |
var enterEvent = $.Event('keyup', { keyCode: 13 }); | |
var main = document.getElementById('main'); | |
var footer = document.getElementById('footer'); | |
it('should not create an empty todo', function() { | |
$('#new-todo').val(' '); | |
$('#new-todo').trigger(enterEvent); | |
var todos_count = $('#todo-list li').length; | |
expect(todos_count).to.equal(0); | |
expect(main.style.display).to.equal('none'); | |
expect(footer.style.display).to.equal('none'); | |
}); | |
it('should have #main hidden', function() { | |
$('#toggle-all').trigger('click'); | |
$('#clear-completed').trigger('click'); | |
expect(main.style.display).to.equal('none'); | |
expect(footer.style.display).to.equal('none'); | |
}); | |
it('should create a todo on Enter', function() { | |
$('#new-todo').val(title); | |
$('#new-todo').trigger(enterEvent); | |
var todo_list = $('#todo-list li'); | |
expect(todo_list.text()).to.match(new RegExp(title, 'i')); | |
expect(todo_list.length).to.equal(1); | |
expect(main.style.display).to.not.equal('none'); | |
expect(footer.style.display).to.not.equal('none'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment