UNPKG

nexshop-web-contents

Version:

Nexshop Web Contents Project

52 lines (43 loc) 2.11 kB
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; }); });