-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
87 lines (64 loc) · 2.56 KB
/
test.js
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
var assert = require('assert');
var collapse = require('./index.js');
var PluginApi = require('gardr-core-plugin').PluginApi;
function mockItem(width, height) {
return {
rendered: {
width: width,
height: height
},
options: {
container: {
style: {
display: 'block'
}
}
}
};
}
describe('Collapse plugin', function() {
var pluginApi;
var options = {
collapseIfWidthLessThan: 15,
collapseIfHeightLessThan: 15
};
beforeEach(function() {
pluginApi = new PluginApi();
})
it('should collapse section if height smaller than default value 10 px', function() {
var item = mockItem(100, 9);
collapse(pluginApi);
pluginApi.trigger('item:afterrender', item);
assert.equal(item.options.container.style.display, 'none', 'Display should be none');
});
it('should collapse section if width smaller than default value 10 px', function() {
var item = mockItem(9, 100);
collapse(pluginApi);
pluginApi.trigger('item:afterrender', item);
assert.equal(item.options.container.style.display, 'none', 'Display should be none');
});
it('should not collapse section if width and height are larger than default 10 px', function() {
var item = mockItem(100, 100);
collapse(pluginApi);
pluginApi.trigger('item:afterrender', item);
assert.equal(item.options.container.style.display, 'block', 'Display should be block');
});
it('should collapse section if width smaller than value provided in options', function() {
var item = mockItem(14, 140);
collapse(pluginApi, options);
pluginApi.trigger('item:afterrender', item);
assert.equal(item.options.container.style.display, 'none', 'Display should be none');
});
it('should collapse section if height smaller than value provided in options', function() {
var item = mockItem(140, 14);
collapse(pluginApi, options);
pluginApi.trigger('item:afterrender', item);
assert.equal(item.options.container.style.display, 'none', 'Display should be none');
});
it('should not collapse section if width and height larger than values provided in options', function() {
var item = mockItem(100, 100);
collapse(pluginApi, options);
pluginApi.trigger('item:afterrender', item);
assert.equal(item.options.container.style.display, 'block', 'Display should be block');
});
})