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;
});
}); |