UNPKG

nexshop-web-contents

Version:

Nexshop Web Contents Project

45 lines (37 loc) 1.7 kB
import React from 'react'; import {expect} from 'chai'; import {shallow} from 'enzyme'; import sinon from "sinon"; import PlayListTitleView from '../../../src/component/playlist/playlist-title-view'; describe('Playlist Title View Spec', () => { let wrapper; let spyOnPreviewClick; let spyOnSavePlaylist; beforeEach(() => { spyOnPreviewClick = sinon.spy(); spyOnSavePlaylist = sinon.spy(); wrapper = shallow(<PlayListTitleView name={'some title'} hasPlaylistItem={false} onPreviewClick={spyOnPreviewClick} onSavePlaylist={spyOnSavePlaylist} />); }); it('has name with given by "createPlaylist"', () => { expect(wrapper.find('.top-bar-sub__title').text()).to.equals('some title'); }); it('enable buttons depend on props.hasPlaylistItem', () => { expect(wrapper.find('.top-bar-sub-menu__item--inactive').length).to.equal(2); wrapper.setProps({'hasPlaylistItem': true}); expect(wrapper.find('.top-bar-sub-menu__item').length).to.equal(2); }); it('calls props.onPreviewClick when PREVIEW Button is clicked', () => { wrapper.setProps({'hasPlaylistItem': true}); wrapper.find('.top-bar-sub-menu__item').at(0).simulate('click'); expect(spyOnPreviewClick.called).to.be.true; }); it('calls spyOnSavePlaylist when save button clicked', () => { wrapper.setProps({'hasPlaylistItem': true}); wrapper.find('.top-bar-sub-menu__item').at(1).simulate('click'); expect(spyOnSavePlaylist.called).to.be.true; }); });