import {IJQueryViewModel, expect, spy, render} from '@dezrez/testing'; import {Nested, INestedProps} from '../../app/widgets/nested/nested'; describe('Nested Component' , () => { let $el: IJQueryViewModel; beforeEach(() => { const description$ = ko.observable(0); $el = render({ template: Nested.prototype.view, viewModel: Nested }, { description: description$, update: () => { let currValue = description$(); description$(++currValue); } }); }); afterEach(() => { $el.dispose(); }); it('renders', () => { expect($el).to.exist; }); it('it updates', () => { const updateSpy = spy($el.$data().update); expect($el.find('button')).to.exist; expect($el.find('span').html()).to.equal('0'); $el.find('button').simulate('click'); expect($el.find('span').html()).to.equal('1'); expect($el.$data().description()).equals(1); expect(updateSpy).to.be.called; }); });