forked from 15001217168/mojs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsurface.spec.js
More file actions
125 lines (100 loc) · 2.69 KB
/
Copy pathsurface.spec.js
File metadata and controls
125 lines (100 loc) · 2.69 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
var Surface = mojs.Surface;
var Html = mojs.Html;
var helpers = mojs.__helpers__;
describe('`surface` ->', function () {
describe('extension ->', function() {
it('should extend `Html`', function () {
var surface = new Surface();
expect(Html.__mojsClass.isPrototypeOf(surface)).toBe(true);
});
});
describe('element creation ->', function() {
it('should create DOM element', function () {
var surface = new Surface();
expect(surface.el + '').toBe('[object HTMLDivElement]');
});
it('should append el to parent', function () {
var parent = document.createElement('div');
var surface = new Surface({
parent: parent
});
expect(surface.el.parentNode).toBe(parent);
});
});
describe('`_defaults` creation ->', function() {
it('should declared `_defaults`', function () {
var surface = new Surface();
expect(surface._defaults).toEqual({
parent: document.body,
width: 100,
height: 100,
is3d: false,
el: null,
customProperties: {},
x: 0,
y: 0,
z: 0,
skewX: 0,
skewY: 0,
angle: 0,
angleX: 0,
angleY: 0,
angleZ: undefined,
scale: 1,
scaleX: undefined,
scaleY: undefined,
scaleZ: undefined,
});
});
it('should save `Html` defaults', function () {
var surface = new Surface();
expect(surface._htmlDefaults).toEqual({
is3d: false,
el: null,
customProperties: {},
x: 0,
y: 0,
z: 0,
skewX: 0,
skewY: 0,
angle: 0,
angleX: 0,
angleY: 0,
angleZ: undefined,
scale: 1,
scaleX: undefined,
scaleY: undefined,
scaleZ: undefined,
});
});
});
describe('`customProperties` ->', function() {
it('should pass `customProperties` with `width` and `hight` types', function () {
var spam = 2;
var eggs = 1;
var surface = new Surface({
spam: spam,
eggs: eggs
});
expect(surface._o.customProperties.height.type).toBe('unit');
expect(surface._o.customProperties.width.type).toBe('unit');
});
it('should pipe passed `customProperties`', function () {
var spam = 2;
var eggs = 1;
var render = function() {};
var surface = new Surface({
spam: spam,
eggs: eggs,
customProperties: {
spam: {
type: 'color'
},
render: render
}
});
expect(surface._o.customProperties.spam.type).toBe('color');
expect(surface._o.customProperties.render).toBe(render);
});
});
});