all files / containers/Counter/ index.test.tsx

100% Statements 25/25
100% Branches 0/0
100% Functions 8/8
100% Lines 25/25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                           
"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');
    });
});