All files / nexshop-web-contents/spec/component/scene/scene-resource scene-layout-item-view-spec.js

100% Statements 17/17
100% Branches 0/0
100% Functions 3/3
100% Lines 17/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 251x 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 {shallow} from "enzyme";
import sinon from "sinon";
import SceneLayoutItemView from "../../../../src/component/scene/scene-resource/scene-layout-item-view";
 
describe('Scene Layout Item View Spec', () => {
    let wrapper;
    const spyChangeLayout = sinon.spy();
    const orientationHorizontal = 'horizontal';
    const orientationVertical = 'vertical';
 
    it('render scene-layout--selected when layout id is selectedLayoutId', () => {
        wrapper = shallow(<SceneLayoutItemView changeLayout={spyChangeLayout} orientation={orientationHorizontal} selectedLayoutId={'1'}/>);
        let layoutWithId_1 = wrapper.find('.scene-layout-wrapper').at(0);
 
        expect(layoutWithId_1.find('.scene-layout--selected').length).to.equal(1);
    });
 
    it('call changeLayout when item click ', () => {
        wrapper = shallow(<SceneLayoutItemView changeLayout={spyChangeLayout} orientation={orientationVertical} selectedLayoutId={'1'}/>);
        wrapper.find('.scene-layout-1-1').at(0).simulate('click');
        expect(spyChangeLayout.calledWith('1')).to.be.true;
    });
});