All files / nexshop-web-contents/spec/component/scene scene-title-view-spec.js

100% Statements 28/28
100% Branches 0/0
100% Functions 7/7
100% Lines 28/28
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 521x 1x 1x 1x 1x   1x     1x 1x   1x 4x 4x           1x 4x     1x 1x     1x 1x 1x   1x     1x     1x 1x   1x 1x     1x 1x   1x 1x    
import React from 'react';
import {expect} from 'chai';
import sinon from "sinon";
import {shallow} from "enzyme";
import SceneTitleView from "../../../src/component/scene/scene-title-view";
 
describe('Scene Title View Spec', () => {
    let wrapper;
    let title;
    const spySaveScene = sinon.spy();
    const spyOnPreviewClick = sinon.spy();
 
    beforeEach(() => {
        title = 'New Scene';
        wrapper = shallow(<SceneTitleView title={title}
                                          saveScene={spySaveScene}
                                          onPreviewClick={spyOnPreviewClick}
                                          hasFullContent={false}/>);
    });
 
    afterEach(() => {
        spySaveScene.reset();
    });
 
    it('has title Name', () => {
        expect(wrapper.find('.top-bar-sub__title').text()).to.equals(title);
    });
 
    it('active & inactive save, preview button', () => {
        expect(wrapper.find('.top-bar-sub-menu__item').length).to.equals(0);
        expect(wrapper.find('.top-bar-sub-menu__item--inactive').length).to.equals(2);
 
        wrapper = shallow(<SceneTitleView title={title} saveScene={spySaveScene}
                                          onPreviewClick={spyOnPreviewClick}  hasFullContent={true}/>);
 
        expect(wrapper.find('.top-bar-sub-menu__item').length).to.equals(2);
    });
 
    it('call saveScene when save button click', () => {
        wrapper = shallow(<SceneTitleView title={title} saveScene={spySaveScene}
                                          onPreviewClick={spyOnPreviewClick}  hasFullContent={true}/>);
        wrapper.find('.top-bar-sub-menu__item').at(1).simulate('click');
        expect(spySaveScene.called).to.be.true;
    });
 
    it('call onPreviewClick when preview button click', () => {
        wrapper = shallow(<SceneTitleView title={title} saveScene={spySaveScene}
                                          onPreviewClick={spyOnPreviewClick}  hasFullContent={true}/>);
        wrapper.find('.top-bar-sub-menu__item').at(0).simulate('click');
        expect(spyOnPreviewClick.called).to.be.true;
    });
});