All files / nexshop-web-contents/spec/component/contents contents-spec.js

100% Statements 239/239
100% Branches 0/0
100% Functions 70/70
100% Lines 239/239
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 6041x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x                                     1x 1x 1x 1x   1x                                         1x     43x   43x   43x     1x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x   41x                                                                                                           41x                                                                     41x 41x       1x 41x     1x 1x 1x     1x 1x       1x 1x     1x 1x 1x     1x 1x   1x     1x 1x 1x 1x 1x   1x       1x 1x 1x 1x 1x     1x 1x 1x 1x     1x 1x 1x 1x       1x 1x 1x 1x   1x 1x     1x 1x   1x       1x 1x   1x         1x 1x 1x     1x 1x     1x 1x                                           1x 1x                                                         1x 1x 1x   1x 1x 1x   1x     1x 1x 1x 1x   1x         1x 1x 3x         1x 1x   1x 1x 1x   1x     1x 1x   1x 1x 1x   1x     1x 1x                 1x   1x       1x 1x 1x         1x   1x     1x 1x         1x   1x     1x   1x 1x   1x 1x     1x 1x   1x 1x     1x 1x   1x       1x 1x 1x 1x     1x   1x   1x 1x       1x 1x 1x   1x     1x 1x   1x       1x 1x 1x 1x 1x   1x 1x       1x 1x 1x 1x 1x   1x 1x                         1x 1x 1x   1x 1x       1x 1x 1x   1x 1x       1x 1x 1x   1x       1x 1x 1x   1x 4x     4x   4x         1x 4x     1x 1x   1x     1x 1x   1x     1x 1x   1x     1x 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 {mount, shallow} from "enzyme";
import configureStore from 'redux-mock-store';
import sinon from 'sinon';
import * as Redux from 'redux';
import {actions as dialogActions} from "nexshop-web-dialog";
import {contentsActions, playlistActions, sceneActions, previewActions} from 'nexshop-web-store';
import {actions as popupActions} from "nexshop-web-popup";
import Contents from '../../../src/component/contents/contents';
import {closeFloatingView, openFloatingView} from '../../../src/action/floating-view';
import ContentsView from '../../../src/component/contents/contents-view';
import FloatingView from '../../../src/component/contents/floating-view/floating-view';
 
const {
    fetchContentsAsync,
    willBeDeletedContentsItem,
    selectContentsItemForPreview,
    selectUploadFiles,
    uploadFilesAsync,
    removeSelectedContentsItemIndex,
    setSelectedContentsItemIndex,
    updateFolderAsync,
    updateFolderData,
    fetchAllUnderFolderAsync,
    pushFolderBreadcrumb,
    popFolderBreadcrumb,
    setSelectedContentsItemIds,
    updateContentsItemData,
    updateContentsItemAsync,
    copyContents,
} = contentsActions;
 
const {playlistDetailAsync} = playlistActions;
const {playlistPreviewAsync} = previewActions;
const {moveSceneDetailAsync} = sceneActions;
const {closePopup, openPopup, closeAllPopup} = popupActions;
 
describe('Contents Spec', () => {
    let wrapper, instance;
    let spyOpenFloatingView, spyCloseFloatingView, spyFetchContentsAsync,
        spyWillBeDeletedContentsItem, spySelectContentsItemForPreview,
        spyOpenDialog, spyClosePopup, spyOpenPopup, spyUpdateFolderData,
        spyPushFolderBreadcrumb, spyPopFolderBreadcrumb,
        spyFetchAllUnderFolderAsync, spyCloseAllPopup;
    let spySelectUploadFiles;
    let spyUploadFilesAsync;
    let spySetSelectedContentsItemIndex;
    let spyRemoveSelectedContentsItemIndex;
    let spyUpdateFolderAsync;
    let spyPlaylistPreviewAsync;
    let spyPlaylistDetailAsync;
    let spyMoveSceneDetailAsync;
    let spySetSelectedContentsItemIds;
    let spyUpdateContentsItemData;
    let spyUpdateContentsItemAsync;
    let storeState, mockStore;
    let spyCopyContents;
 
    const {openDialog} = dialogActions;
 
    function getWrapperAndInstance(mockStore) {
        wrapper = shallow(<Contents store={mockStore}/>).dive();
 
        instance = wrapper.instance();
 
        return {wrapper, instance};
    }
 
    beforeEach(() => {
        spyOpenFloatingView = sinon.spy();
        spyCloseFloatingView = sinon.spy();
        spyFetchContentsAsync = sinon.spy();
        spyWillBeDeletedContentsItem = sinon.spy();
        spySelectContentsItemForPreview = sinon.spy();
        spyOpenDialog = sinon.spy();
        spySelectUploadFiles = sinon.spy();
        spyUploadFilesAsync = sinon.spy();
        spyOpenFloatingView = sinon.spy();
        spySetSelectedContentsItemIndex = sinon.spy();
        spyRemoveSelectedContentsItemIndex = sinon.spy();
        spyUpdateFolderAsync = sinon.spy();
        spyPlaylistPreviewAsync = sinon.spy();
        spyMoveSceneDetailAsync = sinon.spy();
        spyClosePopup = sinon.spy();
        spyOpenPopup = sinon.spy();
        spyUpdateFolderData = sinon.spy();
        spyFetchAllUnderFolderAsync = sinon.spy();
        spyPushFolderBreadcrumb = sinon.spy();
        spyPopFolderBreadcrumb = sinon.spy();
        spyCloseAllPopup = sinon.spy();
        spySetSelectedContentsItemIds = sinon.spy();
        spyUpdateContentsItemData = sinon.spy();
        spyUpdateContentsItemAsync = sinon.spy();
        spyPlaylistDetailAsync = sinon.spy();
        spyCopyContents = sinon.spy();
 
        sinon.stub(Redux, "bindActionCreators").withArgs({
            openFloatingView,
            closeFloatingView,
            fetchContentsAsync,
            willBeDeletedContentsItem,
            selectContentsItemForPreview,
            selectUploadFiles,
            uploadFilesAsync,
            openDialog,
            setSelectedContentsItemIndex,
            removeSelectedContentsItemIndex,
            updateFolderAsync,
            playlistPreviewAsync,
            playlistDetailAsync,
            moveSceneDetailAsync,
            updateFolderData,
            fetchAllUnderFolderAsync,
            pushFolderBreadcrumb,
            popFolderBreadcrumb,
            openPopup,
            closePopup,
            closeAllPopup,
            setSelectedContentsItemIds,
            updateContentsItemData,
            updateContentsItemAsync,
            copyContents,
        }, sinon.match.func).returns({
            closeFloatingView: spyCloseFloatingView,
            fetchContentsAsync: spyFetchContentsAsync,
            willBeDeletedContentsItem: spyWillBeDeletedContentsItem,
            selectContentsItemForPreview: spySelectContentsItemForPreview,
            selectUploadFiles: spySelectUploadFiles,
            uploadFilesAsync: spyUploadFilesAsync,
            openFloatingView: spyOpenFloatingView,
            openDialog: spyOpenDialog,
            setSelectedContentsItemIndex: spySetSelectedContentsItemIndex,
            removeSelectedContentsItemIndex: spyRemoveSelectedContentsItemIndex,
            playlistPreviewAsync: spyPlaylistPreviewAsync,
            playlistDetailAsync: spyPlaylistDetailAsync,
            updateFolderAsync: spyUpdateFolderAsync,
            moveSceneDetailAsync: spyMoveSceneDetailAsync,
            closePopup: spyClosePopup,
            closeAllPopup: spyCloseAllPopup,
            openPopup: spyOpenPopup,
            updateFolderData: spyUpdateFolderData,
            fetchAllUnderFolderAsync: spyFetchAllUnderFolderAsync,
            pushFolderBreadcrumb: spyPushFolderBreadcrumb,
            popFolderBreadcrumb: spyPopFolderBreadcrumb,
            setSelectedContentsItemIds: spySetSelectedContentsItemIds,
            updateContentsItemData: spyUpdateContentsItemData,
            updateContentsItemAsync: spyUpdateContentsItemAsync,
            copyContents: spyCopyContents,
        });
 
        storeState = {
            floatingView: {visibility: true},
            contents: {
                selectedUploadFiles: [{name: '1', type:'mock/one'}, {name: '2', type:'mock/two'}],
                contents: [{
                    id: 'some id', name: 'media1', status: 'selected', type: 'playlist', thumbnailUrls: {
                        thumbnail: 'some url',
                        medium: null,
                        large: null
                    }
                }, {
                    id: 'other id', name: 'media2', type: 'image', thumbnailUrls: {
                        thumbnail: 'some url',
                        medium: null,
                        large: null
                    }
                }, {
                    id: 'scene id', name: 'scene sample', type: 'scene', thumbnailUrls: {
                        thumbnail: 'scene some url',
                        medium: null,
                        large: null
                    }
                }],
                folders: [{id: 'folder id', name: 'folder1'}, {id: '2', name: 'folder2'}],
                breadcrumb: [{name: 'RootFolder', id: 'rootId'}],
                selectedContentsItemIds: [],
                searchOption: {
                    name: '',
                    type: 'all'
                },
            },
            popup: {},
            contextMenuOpenedIndex: -1,
        };
 
        mockStore = configureStore()(storeState);
        ({instance, wrapper} = getWrapperAndInstance(mockStore));
 
    });
 
    afterEach(() => {
        Redux.bindActionCreators.restore();
    });
 
    describe('Contents', () => {
        it('passes contents to ContentsView', () => {
            expect(wrapper.find(ContentsView).prop('contents').length).to.equal(3);
        });
 
        it('passes folders to FolderView', () => {
            expect(wrapper.find(ContentsView).prop('folders')).to.deep.equal(
                [{id: 'folder id', name: 'folder1'}, {id: '2', name: 'folder2'}]);
        });
 
        it('draws floating view when floatingViewVisibility is true', () => {
            expect(wrapper.find(FloatingView).length).to.equal(1);
        });
 
        it('passes files, onClose props to FloatingView', () => {
            expect(wrapper.find(FloatingView).prop('files')).to.deep.equal([{name: '1', type:'mock/one'}, {name: '2', type:'mock/two'}]);
            expect(wrapper.find(FloatingView).prop('onClose')).to.equal(spyCloseFloatingView);
        });
 
        it('does not draw floating view when floatingViewVisibility is false', () => {
            wrapper.setProps({floatingViewVisibility: false});
 
            expect(wrapper.find(FloatingView).length).to.equal(0);
        });
 
        describe('onContentsClick', () => {
            it('passes onContentItemClick with contentsItemSelected', () => {
                let {onContentsClick} = wrapper.find(ContentsView).props();
                const spyContentsSelectedAndPlaylistAsync = sinon.spy(wrapper.instance(), 'contentsItemSelected');
                onContentsClick(undefined, 0);
 
                expect(spyContentsSelectedAndPlaylistAsync.called).to.true;
            });
        });
 
        describe('onContentItemDoubleClick', () => {
            it('passes playlistDetailAsync with playlist type contentsItem', () => {
                let {onContentItemDoubleClick} = wrapper.find(ContentsView).props();
                onContentItemDoubleClick((0));
                expect(spyPlaylistDetailAsync.calledWith('some id', '/contents/playlist-detail')).to.true;
            });
 
            it('could not call playlistDetailAsync with non-playlist type contentsItem', () => {
                let {onContentItemDoubleClick} = wrapper.find(ContentsView).props();
                onContentItemDoubleClick(1);
                expect(spyPlaylistDetailAsync.called).to.false;
            });
 
            it('call moveSceneDetailAsync, history push with scene type id', () => {
                let {onContentItemDoubleClick} = wrapper.find(ContentsView).props();
                onContentItemDoubleClick(2);
                expect(spyMoveSceneDetailAsync.calledWith('scene id')).to.true;
            });
        });
 
        describe('onContextMenuClicked', () => {
            it('call ContextMenuClicked method', () => {
                let {onContextMenuClicked} = wrapper.find(ContentsView).props();
                const spyContextMenuClicked = sinon.spy(wrapper.instance(), "contextMenuClicked");
 
                onContextMenuClicked(undefined, 0);
                expect(spyContextMenuClicked.calledWith(undefined, 0 )).to.true;
            });
 
            it('call setSelectedContentsItemIds with folder', () => {
                wrapper.instance().contextMenuClicked(undefined, 0);
 
                expect(spySetSelectedContentsItemIds.calledWith(['folder id'])).to.true;
            });
 
 
            it('call setSelectedContentsItemIds with playlist contents item', () => {
                wrapper.instance().contextMenuClicked('playlist', 0);
 
                expect(spySetSelectedContentsItemIds.calledWith(['some id'])).to.true;
            });
        });
    });
 
    describe('Mapping props', () => {
        it('has props.floatingViewVisibility as true when redux floatingView visibility state is true', () => {
            expect(instance.props.floatingViewVisibility).to.be.true;
        });
 
        it('has props.selectedUploadFiles as redux contents selectedUploadFiles state', () => {
            expect(instance.props.selectedUploadFiles).to.deep.equal([{name: '1', type:'mock/one'}, {name: '2', type:'mock/two'}]);
        });
 
        it('has props.contents as redux contents state', () => {
            expect(instance.props.contents).to.deep.equal(
                [{
                    id: 'some id', name: 'media1', status: 'selected', type: 'playlist', thumbnailUrls: {
                        thumbnail: 'some url',
                        medium: null,
                        large: null
                    }
                }, {
                    id: 'other id', name: 'media2', type: 'image', thumbnailUrls: {
                        thumbnail: 'some url',
                        medium: null,
                        large: null
                    }
                }, {
                    id: 'scene id', name: 'scene sample', type: 'scene', thumbnailUrls: {
                        thumbnail: 'scene some url',
                        medium: null,
                        large: null
                    }
                }]);
        });
 
        it('has action openDialog and openPopup', () => {
            expect(instance.props.actions).to.deep.equal({
                closeFloatingView: spyCloseFloatingView,
                fetchContentsAsync: spyFetchContentsAsync,
                willBeDeletedContentsItem: spyWillBeDeletedContentsItem,
                selectContentsItemForPreview: spySelectContentsItemForPreview,
                selectUploadFiles: spySelectUploadFiles,
                uploadFilesAsync: spyUploadFilesAsync,
                openFloatingView: spyOpenFloatingView,
                openDialog: spyOpenDialog,
                setSelectedContentsItemIndex: spySetSelectedContentsItemIndex,
                removeSelectedContentsItemIndex: spyRemoveSelectedContentsItemIndex,
                updateFolderAsync: spyUpdateFolderAsync,
                playlistPreviewAsync: spyPlaylistPreviewAsync,
                playlistDetailAsync: spyPlaylistDetailAsync,
                closePopup: spyClosePopup,
                openPopup: spyOpenPopup,
                closeAllPopup: spyCloseAllPopup,
                moveSceneDetailAsync: spyMoveSceneDetailAsync,
                updateFolderData: spyUpdateFolderData,
                fetchAllUnderFolderAsync: spyFetchAllUnderFolderAsync,
                pushFolderBreadcrumb: spyPushFolderBreadcrumb,
                popFolderBreadcrumb: spyPopFolderBreadcrumb,
                setSelectedContentsItemIds: spySetSelectedContentsItemIds,
                updateContentsItemData: spyUpdateContentsItemData,
                updateContentsItemAsync: spyUpdateContentsItemAsync,
                copyContents: spyCopyContents
            });
        });
 
        describe('contextMenuVisibility ', () => {
            it('contextMenuVisibility is not true when popup do not have "context-menu" or visibility is false', () => {
                expect(wrapper.instance().props.contextMenuVisibility).to.not.true;
 
                storeState.popup = {'context-menu': {visibility: false}};
                mockStore = configureStore()(storeState);
                ({instance, wrapper} = getWrapperAndInstance(mockStore));
 
                expect(wrapper.instance().props.contextMenuVisibility).to.not.true;
            });
 
            it('contextMenuVisibility is true when popup do have "context-menu" and visibility is true', () => {
                storeState.popup = {'context-menu': {visibility: true}};
                mockStore = configureStore()(storeState);
                ({instance, wrapper} = getWrapperAndInstance(mockStore));
 
                expect(wrapper.instance().props.contextMenuVisibility).to.true;
            });
        });
    });
 
    describe('restore selected td column', () => {
        beforeEach(() => {
            wrapper.setProps({
                contents: []
            });
        });
 
        it('calls removeSelectedContentItemIndex func when body click', () => {
            wrapper = mount(<Contents store={mockStore} updateFolderAsync={sinon.spy()}/>);
 
            let evt = document.createEvent("HTMLEvents");
            evt.initEvent("click", false, true);
            document.body.dispatchEvent(evt);
 
            expect(spyRemoveSelectedContentsItemIndex.called).to.be.true;
        });
 
        it('Document Body has not removeSelectedContentsItem func when Contents unmounted', () => {
            wrapper.instance().componentWillUnmount();
 
            let evt = document.createEvent("HTMLEvents");
            evt.initEvent("click", false, true);
            document.body.dispatchEvent(evt);
 
            expect(spyRemoveSelectedContentsItemIndex.called).to.be.false;
        });
 
        it('does not call removeSelectedContentsItemIndex when calls removeSelectedContentsItem func with TD target ', () => {
            const e = {
                target: {
                    nodeName: 'TD',
                    parentNode: {
                        nodeName: 'TD'
                    }
                }
            };
 
            wrapper.instance().removeSelectedContentsItem(e);
 
            expect(spyRemoveSelectedContentsItemIndex.called).to.be.false;
        });
    });
 
    describe('method test', () => {
        it('calls setSelectedContentsItemIndex when contentsItemSelected with contentsItem', () => {
            const contentsItem = {
                type: 'playlist',
                id: 'some id'
            };
 
            wrapper.instance().contentsItemSelected([contentsItem.id]);
 
            expect(spySetSelectedContentsItemIds.calledWith(['some id'])).to.true;
        });
 
        it('calls playlistDetailAsync when contentsItemDetailAsync with playlist type contentsItem', () => {
            const contentsItem = {
                type: 'playlist',
                id: 'some id'
            };
 
            wrapper.instance().contentsItemDetailAsync(contentsItem);
 
            expect(spyPlaylistDetailAsync.calledWith('some id', '/contents/playlist-detail')).to.true;
        });
 
        describe('when ContextMenuClicked with index 1', () => {
 
            it('and folder type then call openPopup and closeAllPopup action', () => {
                wrapper.instance().contextMenuClicked(undefined, 1);
 
                expect(spyOpenPopup.calledWith("context-menu")).to.true;
                expect(spyCloseAllPopup.called).to.true;
            });
 
            it('and contents item type then call openPopup and closeAllPopup action', () => {
                wrapper.instance().contextMenuClicked('image', 1);
 
                expect(spyOpenPopup.calledWith("context-menu")).to.true;
                expect(spyCloseAllPopup.called).to.true;
            });
 
            it('then contextMenuOpenedIndex should be 1', () => {
                wrapper.instance().contextMenuClicked(undefined, 1);
 
                expect(wrapper.instance().state.contextMenuOpenedIndex).to.equal(1);
            });
        });
 
        describe('when ContextMenuClicked with index 1 and contextMenuOpenedIndex was 1', () => {
            it('then contextMenuOpenedIndex should not change and does not called contentsItemSelected', () => {
                const beforeContextMenuOpenedIndex = 1;
                wrapper.setState({
                    contextMenuOpenedIndex: beforeContextMenuOpenedIndex
                });
                const spyContentsItemSelected = sinon.spy(wrapper.instance(), 'contentsItemSelected');
 
                wrapper.instance().contextMenuClicked(undefined, 1);
 
                expect(wrapper.instance().state.contextMenuOpenedIndex).to.equal(beforeContextMenuOpenedIndex);
                expect(spyContentsItemSelected.called).to.false;
            });
        });
 
        describe('when calls closeContextMenuPopup', () => {
            it('then contextMenuOpenedIndex state is -1', () => {
                wrapper.instance().closeContextMenuPopup();
 
                expect(wrapper.instance().state.contextMenuOpenedIndex).to.equal(-1);
            });
 
            it('then call closePopup', () => {
                wrapper.instance().closeContextMenuPopup();
 
                expect(spyCloseAllPopup.called).to.true;
            });
        });
 
        describe('when calls rename with folder', () => {
            it('then closeContextMenuPopup and updateFolderData method call', () => {
                const closeContextMenuPopup = sinon.spy(wrapper.instance(), 'closeContextMenuPopup');
                wrapper.instance().setState({contextMenuOpenedIndex: 0});
                wrapper.instance().rename(undefined);
 
                expect(closeContextMenuPopup.called).to.true;
                expect(spyUpdateFolderData.calledWith({id: 'folder id', name: 'folder1', status: 'new'})).to.true;
            });
        });
 
        describe('when calls rename with contentsItem', () => {
            it('then closeContextMenuPopup and updateContentsItemData method call', () => {
                const closeContextMenuPopup = sinon.spy(wrapper.instance(), 'closeContextMenuPopup');
                wrapper.instance().setState({contextMenuOpenedIndex: 0});
                wrapper.instance().rename('playlist');
 
                expect(closeContextMenuPopup.called).to.true;
                expect(spyUpdateContentsItemData.calledWith(
                    {
                        id: 'some id', name: 'media1', type: 'playlist',
                        thumbnailUrls: {
                            thumbnail: 'some url',
                            medium: null,
                            large: null
                        }
                        , status: 'new'
                    })).to.true;
            });
        });
 
        describe('when calls onFolderItemDoubleClick', () => {
            it('then call spyPushFolderBreadcrumb and fetchAllUnderFolderAsync', () => {
                wrapper.instance().onFolderItemDoubleClick({name: 'some folder name', id: 'someFolderId'});
 
                expect(spyPushFolderBreadcrumb.calledWith({name: 'some folder name', id: 'someFolderId'})).to.true;
                expect(spyFetchAllUnderFolderAsync.calledWith('someFolderId')).to.true;
            });
        });
 
        describe('when calls onBreadcrumbItemClick', () => {
            it('then call spyPopFolderBreadcrumb and spyFetchAllUnderFolderAsync', () => {
                wrapper.instance().onBreadcrumbItemClick('some folder id', 1);
 
                expect(spyPopFolderBreadcrumb.calledWith(1));
                expect(spyFetchAllUnderFolderAsync.calledWith('some folder id'));
            });
        });
 
        describe('when calls contentsItemSelected', () => {
            it('set contentsItem id to setSelectedContentsItemIds', () => {
                wrapper.instance().contentsItemSelected(['contentsId']);
 
                expect(spySetSelectedContentsItemIds.calledWith(['contentsId'])).to.true;
            });
        });
 
        describe('moveToPreview Spec', () => {
            const playlistId = 'some id';
            const notPlaylistId = 'other id';
 
            beforeEach(() => {
                wrapper.setProps({
                    history: {push: sinon.spy()}
                });
                sinon.stub(document, 'getElementById').returns({
                    getClientRects: () => {
                        return [{width: 16, height: 9}]
                    }
                });
            });
 
            afterEach(() => {
                document.getElementById.restore();
            });
 
            it('call selectContentsItemForPreview when moveToPreview executed', () => {
                wrapper.instance().moveToPreview(playlistId);
 
                expect(spySelectContentsItemForPreview.calledWith(playlistId)).to.be.true;
            });
 
            it('route to "/contents/contents-preview" when contentsItem type is not playlist', () => {
                wrapper.instance().moveToPreview(notPlaylistId);
 
                expect(wrapper.instance().props.history.push.calledWith('/contents/contents-preview')).to.be.true;
            });
 
            it('call playlistPreviewAsync when contentsItem type is playlist', () => {
                wrapper.instance().moveToPreview(playlistId);
 
                expect(spyPlaylistPreviewAsync.calledWith(playlistId, {width: 16, height: 9})).to.be.true;
            });
            
            it('when show preview then close context popup.', () => {
                wrapper.instance().contextMenuClicked(undefined, 1);
                wrapper.instance().moveToPreview(playlistId);
 
                expect(spyCloseAllPopup.called).to.true;
            });
        });
 
        describe('when calls moveToClick', () => {
            it('then call closePopup', () => {
                wrapper.instance().moveToClick();
 
                expect(spyCloseAllPopup.called).to.true;
            });
        });
 
        describe('when calls copyToClick', () => {
            it('then call closePopup', () => {
                 wrapper.instance().copyToClick('playlist', 0);
 
                 expect(spyCloseAllPopup.called).to.true;
                 expect(spyCopyContents.calledWith(wrapper.instance().getIdForType('playlist', 0))).to.true;
            });
 
        });
    });
 
    describe('pass props', () => {
        describe('ContentsView', () => {
            it('pass moveToPreview for onPreview', () => {
                expect(wrapper.find(ContentsView).prop('onPreview')).to.equal(wrapper.instance().moveToPreview);
            });
        });
    });
});