"use strict";
var chai_1 = require('chai');
var TestHelper_1 = require('../../helpers/TestHelper');
var index_1 = require('./index');
/** Mock App. State */
var state = {
counter: { count: 1 },
};
describe('<Counter />', function () {
var component;
beforeEach(function () {
component = TestHelper_1.renderComponent(index_1.Counter, state);
});
it('Renders with correct style', function () {
var s = require('./style.css');
chai_1.expect(component.find(s.counter)).to.exist;
});
it('Renders header', function () {
chai_1.expect(component.find('h4').text()).to.eql('Counter Example');
});
it('Renders Increment and Decrement buttons', function () {
chai_1.expect(component.find('button')).to.have.length(2);
});
it('Renders counter value', function () {
chai_1.expect(component.find('p').text()).to.eql('1');
});
it('Calls the increment', function () {
chai_1.expect(component.find({ name: 'incBtn' })).to.exist;
component.find({ name: 'incBtn' }).simulate('click');
chai_1.expect(component.find('p').text()).to.eql('2');
});
it('Calls the decrement', function () {
chai_1.expect(component.find({ name: 'decBtn' })).to.exist;
component.find({ name: 'decBtn' }).simulate('click');
chai_1.expect(component.find('p').text()).to.eql('0');
});
});
|