| 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 | 1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
1x
3x
3x
3x
3x
1x
3x
1x
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 * as Redux from 'redux';
import sinon from "sinon";
import ContentsMini from "../../../../src/component/playlist/contents-mini/contents-mini";
import {playlistActions} from "nexshop-web-store";
const contents = [
{
id: 1,
name: 'first.file',
type: 'image',
thumbnailUrls: {
thumbnail: 'first.thumbnail.file',
},
},
{
id: 2,
name: 'second.file',
type: 'video',
thumbnailUrls: {
thumbnail: 'second.thumbnail.file'
}
},
{
id: 3,
name: 'third.file',
type: 'playlist',
thumbnailUrls: {
thumbnail: 'third.thumbnail.file'
}
},
];
const folders = [
{
id: '1',
name: 'first folder',
parentId: 'root'
},
{
id: '2',
name: 'second folder',
parentId: 'root'
},
{
id: '3',
name: 'third folder',
parentId: 'root'
},
];
describe('Contents Mini Spec', () => {
let wrapper;
let mockStore;
let spyStartDragContentsItem;
const {startDragContentsItem} = playlistActions;
beforeEach(() => {
mockStore = configureStore()({contents: {contentsMini: contents, foldersMini: folders}});
spyStartDragContentsItem = sinon.spy();
sinon.stub(Redux, "bindActionCreators").returns({
startDragContentsItem: spyStartDragContentsItem,
});
wrapper = shallow(<ContentsMini store={mockStore}/>).dive();
});
afterEach(() => {
Redux.bindActionCreators.restore();
});
it('Map props', () => {
const filteredContents = [{
id: 1,
name: 'first.file',
type: 'image',
thumbnailUrls: {
thumbnail: 'first.thumbnail.file',
},
}, {
id: 2,
name: 'second.file',
type: 'video',
thumbnailUrls: {
thumbnail: 'second.thumbnail.file'
}
}];
expect(wrapper.instance().props.contents).to.deep.equal(filteredContents);
});
it('binds actionCreator with startDragContentsItem', () => {
let actions = Redux.bindActionCreators.lastCall.args[0];
const actionsKeys = Object.keys(actions);
expect(actionsKeys).to.deep.equal(['startDragContentsItem']);
expect(actions.startDragContentsItem).to.equal(startDragContentsItem);
});
it('has action startDragContentsItem', () => {
expect(wrapper.instance().props.actions).to.deep.equal({
startDragContentsItem: spyStartDragContentsItem,
});
});
}); |