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

100% Statements 28/28
100% Branches 0/0
88.89% Functions 8/9
100% Lines 28/28
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 841x 1x 1x 1x 1x 1x 1x 1x 1x   1x     1x 1x 3x   3x   3x                                                                             3x     1x 3x 3x     1x 1x     1x 1x     1x 1x 1x     1x 1x      
import React from 'react';
import {expect} from 'chai';
import {shallow} from "enzyme";
import configureStore from 'redux-mock-store';
import sinon from "sinon";
import * as Redux from "redux";
import ContentsPreviewHeaderView from "../../../../src/component/preview/contents/contents-preview-header-view";
import ContentsPreviewDetailView from "../../../../src/component/preview/contents/contents-preview-detail-view";
import ContentsPreview from "../../../../src/component/preview/contents/contents-preview";
 
describe('Contents Preview Spec', () => {
    let wrapper;
    let mockStore;
    let mockHistory = {goBack: () => {}};
    beforeEach(() => {
        sinon.stub(mockHistory, 'goBack');
 
        sinon.stub(Redux, "bindActionCreators").returns({});
 
        mockStore = configureStore()({
            contents: {
                selectedId: '2',
                contents: [
                    {
                        id: '1',
                        name: 'first.file',
                        lastModifiedTimestamp: '2017-09-07T09:15:51.283Z',
                        type: 'image',
                        fileSizeBytes: 213674,
                        thumbnailUrls: {
                            thumbnail: 'first.thumbnail.file',
                        },
                        status: 'new',
                        metaData: {
                            fileSizeBytes: 267779,
                            contentUrl: 'first.metaData.url',
                            mimeType: "image/jpeg"
                        }
                    },
                    {
                        id: '2',
                        name: 'second.file',
                        lastModifiedTimestamp: '2017-09-08T16:15:51.283Z',
                        type: 'video',
                        fileSizeBytes: 12345670,
                        thumbnailUrls: {
                            thumbnail: 'second.thumbnail.file'
                        },
                        metaData: {
                            fileSizeBytes: 267779,
                            contentUrl: 'second.metaData.url',
                            mimeType: "image/jpeg"
                        }
                    },
                ]
            }
        });
 
        wrapper = shallow(<ContentsPreview store={mockStore} history={mockHistory}/>).dive();
    });
 
    afterEach(() => {
        mockHistory.goBack.restore();
        Redux.bindActionCreators.restore();
    });
 
    it('has contents-preview-header-view', () => {
       expect(wrapper.find(ContentsPreviewHeaderView).length).to.equal(1);
    });
 
    it('has contents-preview-detail-view', () => {
        expect(wrapper.find(ContentsPreviewDetailView).length).to.equal(1);
    });
 
    describe('onClickClose', () => {
        beforeEach(() => {
            wrapper.instance().onClickClose();
        });
 
        it('calls history.goBack', () => {
            expect(mockHistory.goBack.called).to.be.true;
        });
    });
});