All files / nexshop-web-contents/spec/reducer popup-spec.js

100% Statements 30/30
100% Branches 0/0
100% Functions 11/11
100% Lines 30/30
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 571x 1x 1x 1x   1x   1x 1x   1x 1x   1x     1x 1x   1x     1x 1x   1x     1x 1x   1x     1x 1x   1x       1x 1x 1x   1x       1x 1x 1x   1x      
import React from 'react';
import {expect} from 'chai';
import {popup} from "../../src/reducer/popup";
import {CLOSE_POPUP, OPEN_POPUP} from "../../src/action/popup";
 
describe('Popup Reducer Spec', () => {
 
    describe('OPEN Popup Action', () => {
        let position = {top: 10, left: 10, uuid: 'asdasdkjhqwe'};
 
        it('without state', () => {
            let nextState = popup(undefined, {type: 'Another Type'});
 
            expect(nextState).to.deep.equal({name: ''});
        });
 
        it('without state "name"', () => {
            let nextState = popup({}, {type: OPEN_POPUP});
 
            expect(nextState).to.deep.equal({name: ''});
        });
 
        it('changes state "name" with action.name', () => {
            let nextState = popup({}, {type: OPEN_POPUP, name: 'handsome name'});
 
            expect(nextState).to.deep.equal({name: 'handsome name'});
        });
 
        it('changes state "name" without position', () => {
            let nextState = popup({}, {type: OPEN_POPUP, name: 'handsome name'});
 
            expect(nextState).to.deep.equal({name: 'handsome name'});
        });
 
        it('changes state "name" with position', () => {
            let nextState = popup({}, {type: OPEN_POPUP, name: 'handsome name',position: position});
 
            expect(nextState).to.deep.equal({name: 'handsome name', position: position});
        });
    });
 
    describe('CLOSE Popup Action', () => {
        it('changes state "name" with "" ', () => {
            let nextState = popup({name: 'some existing'}, {type: CLOSE_POPUP});
 
            expect(nextState).to.equal('');
        });
    });
 
    describe('Default Action', () => {
        it('returns initialState', () => {
            let nextState = popup({}, {type: ''});
 
            expect(nextState).to.deep.equal({});
        });
    });
});