All files / nexshop-web-contents/spec/component/popup/context-menu folder-context-menu-spec.js

100% Statements 19/19
100% Branches 0/0
100% Functions 5/5
100% Lines 19/19
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 331x 1x 1x 1x 1x   1x 1x 1x 1x     1x 2x         1x 2x     1x 1x 1x     1x 1x   1x    
import React from 'react';
import {expect} from 'chai';
import {shallow} from "enzyme";
import sinon from 'sinon';
import FolderContextMenu from '../../../../src/component/popup/context-menu/folder-context-menu';
 
describe('Folder Context Menu Spec', () => {
    const popupPosition = {x: 100, y: 200};
    const spyOnRenameClick = sinon.spy();
    const spyClose = sinon.spy();
    let wrapper;
 
    beforeEach(() => {
        wrapper = shallow(<FolderContextMenu close={spyClose} popupPosition={popupPosition}
                                             onRenameClick={spyOnRenameClick}/>).dive();
 
    });
 
    afterEach(() => {
        spyOnRenameClick.reset();
    });
 
    it('set style left and top by props position', () => {
        expect(wrapper.find('.folder-context-menu-wrapper').at(0).getNode().props.style.left).to.equal(popupPosition.x);
        expect(wrapper.find('.folder-context-menu-wrapper').at(0).getNode().props.style.top).to.equal(popupPosition.y);
    });
 
    it('bind onRenameClick at folder-context-menu-text onClick', () => {
        wrapper.find('.folder-context-menu-text').simulate('click');
 
        expect(spyOnRenameClick.called).to.be.true;
    });
});