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

100% Statements 24/24
100% Branches 0/0
100% Functions 6/6
100% Lines 24/24
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 451x 1x 1x 1x 1x   1x         1x 4x 4x 4x             1x 1x     1x 1x 1x 1x     1x 1x 1x   1x     1x 1x 1x   1x    
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;
    });
});