all files / redux/modules/counter/ counter.test.ts

100% Statements 22/22
100% Branches 0/0
100% Functions 10/10
100% Lines 22/22
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                               
"use strict";
var chai_1 = require('chai');
var counter = require('./counter');
/** Module */
describe('Counter Module', function () {
    /** Actions */
    describe('Actions', function () {
        describe('Increment', function () {
            it('has the correct type', function () {
                var action = counter.increment();
                chai_1.expect(action.type).to.equal(counter.INCREMENT);
            });
        });
        describe('Decrement', function () {
            it('has the correct type', function () {
                var action = counter.decrement();
                chai_1.expect(action.type).to.equal(counter.DECREMENT);
            });
        });
    });
    /** Reducer */
    describe('Reducer', function () {
        var state = { count: 10 };
        it('handles action of type INCREMENT', function () {
            var action = { type: counter.INCREMENT };
            chai_1.expect(counter.counterReducer(state, action)).to.be.eql({ count: state.count + 1 });
        });
        it('handles action of type DECREMENT', function () {
            var action = { type: counter.DECREMENT };
            chai_1.expect(counter.counterReducer(state, action)).to.be.eql({ count: state.count - 1 });
        });
        it('handles actions with unknown type', function () {
            chai_1.expect(counter.counterReducer(state, { type: '' })).to.be.eql({ count: state.count });
        });
    });
});