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

100% Statements 24/24
100% Branches 0/0
100% Functions 9/9
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 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 741x 1x 1x 1x   1x   1x                                           1x                 1x         1x 5x     1x 1x     1x 1x 3x     1x 1x     1x 1x     1x 1x       1x 1x 1x    
import React from 'react';
import {expect} from 'chai';
import {shallow} from "enzyme";
import ContentsPreviewDetailView from "../../../../src/component/preview/contents/contents-preview-detail-view";
 
describe('Contents Preview Detail View Spec', () => {
    let wrapper;
    const IMAGE_CONTENTS = {
                createdTimestamp: "2017-10-25T07:20:34.133Z",
                lastModifiedTimestamp: "2017-10-25T07:20:34.133Z",
                id: "8e907508598b480ca6635dd44a417a12",
                name: "ccc.jpg",
                type: "image",
                metaData: {
                    contentUrl: "http://nexshop-api-gateway-manualtest.ap-northeast-2.elasticbeanstalk.com/api/v1/files/8e907508598b480ca6635dd44a417a12",
                    mimeType: "image/jpeg",
                    dimensions: {
                        width: 600,
                        height: 400
                    },
                },
                fileSizeBytes: 189882,
                revision: 1,
                folderId: "334535",
                thumbnailUrls: {
                    thumbnail: "http://nexshop-api-gateway-manualtest.ap-northeast-2.elasticbeanstalk.com/api/v1/files/8e907508598b480ca6635dd44a417a12?w=120"
                },
            };
 
    const VIDEO_CONTENTS = {
        type: 'video',
        metaData: {
            contentUrl: 'http://nexshop-api-gateway-manualtest.ap-northeast-2.elasticbeanstalk.com/api/v1/files/831d3ea793654233966117af7d95604d',
            type:'video',
            mimeType: "video/mp4",
        }
    };
 
    const BAD_CONTENTS = {
        type: 'none',
        metaData: {},
    };
 
    beforeEach(() => {
        wrapper = shallow(<ContentsPreviewDetailView contents={IMAGE_CONTENTS}/>)
    });
 
    it('show image given image type contents', () => {
        expect(wrapper.find('.contents-preview-detail--image').length).to.equal(1);
    });
 
    describe('video contents', () => {
        beforeEach(() => {
            wrapper.setProps({contents: VIDEO_CONTENTS});
        });
 
        it('show video given video type contents', () => {
            expect(wrapper.find('.contents-preview-detail--video').exists()).to.be.true;
        });
 
        it('has src attribute with thumbnail url', () => {
            expect(wrapper.find('video').prop('src')).to.equal(VIDEO_CONTENTS.metaData.contentUrl);
        });
 
        it('has type attribute with mimeType', () => {
            expect(wrapper.find('video').prop('type')).to.equal("video/mp4");
        });
    });
 
    it('show empty page given empty contents', () => {
        wrapper.setProps({contents: BAD_CONTENTS});
        expect(wrapper.find('.contents-preview-detail').exists()).to.be.true;
    });
});