1 describeComponent('app/js/data/todos', function () {
4 describe('without datastore', function () {
5 beforeEach(function () {
6 this.dataStore = new mocks.DataStore([]);
8 dataStore: this.dataStore
12 it('should add a new entry', function () {
13 var title = 'buy some unicorns';
15 spyOnEvent(document, 'dataTodoAdded');
16 this.component.trigger('uiAddRequested', {
20 expect('dataTodoAdded').toHaveBeenTriggeredOn(document);
21 expect(this.dataStore.data.length).toBe(1);
22 expect(this.dataStore.all()[0].title).toBe(title);
26 describe('with datastore', function () {
27 beforeEach(function () {
28 this.dataStore = new mocks.DataStore();
30 dataStore: this.dataStore
34 it('removes completed', function () {
35 spyOn(this.dataStore, 'destroyAll');
36 this.component.trigger('uiClearRequested');
37 expect(this.dataStore.destroyAll).toHaveBeenCalledWith({ completed: true });