-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
test.web.js
213 lines (152 loc) · 4.56 KB
/
test.web.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
const canvas = document.createElement('canvas')
const context = canvas.getContext('2d')
const getCommandLength = (context) => {
return context._undodata.commands.length
}
const getRedoLength = (context) => {
return context._undodata.redos.length
}
const getCheckpointLength = (context) => {
return context._undodata.checkpoints.length
}
describe('undoCanvas', () => {
describe('enableUndo', () => {
it('should add undo/redo functions', () => {
expect(context).to.not.respondTo('undo')
expect(context).to.not.respondTo('redo')
UndoCanvas.enableUndo(context)
expect(context).to.respondTo('undo')
expect(context).to.respondTo('redo')
})
it('should record fillStyle', () => {
expect(getCommandLength(context)).to.equal(0)
context.fillStyle = '#aabbcc'
expect(getCommandLength(context)).to.equal(1)
expect(context._undodata.commands[0].args[0]).to.deep.equal('#aabbcc')
})
it('should record font', () => {
context.font = 'Arial'
expect(getCommandLength(context)).to.equal(2)
expect(context._undodata.commands[1].args[0]).to.deep.equal('Arial')
})
it('should record globalAlpha', () => {
context.globalAlpha = 0.8
expect(getCommandLength(context)).to.equal(3)
expect(context._undodata.commands[2].args[0]).to.deep.equal(0.8)
})
it('should record globalCompositeOperation', () => {
context.globalCompositeOperation = 'source-in'
expect(getCommandLength(context)).to.equal(4)
expect(context._undodata.commands[3].args[0]).to.deep.equal('source-in')
})
it('should record lineCap', () => {
})
it('should record lineDashoffset', () => {
})
it('should record lineJoin', () => {
})
it('should record lineWidth', () => {
})
it('should record miterLimit', () => {
})
it('should record shadowBlur', () => {
})
it('should record shadowColor', () => {
})
it('should record shadowOffsetX', () => {
})
it('should record shadowOffsetY', () => {
})
it('should record strokeStyle', () => {
})
it('should record textAlign', () => {
})
it('should record textBaseline', () => {
})
it('should record beginPath()', () => {
})
it('should record arc()', () => {
})
it('should record arcTo()', () => {
})
it('should record bezierCurveTo()', () => {
})
it('should record ellipse()', () => {
})
it('should record moveTo()', () => {
})
it('should record lineTo()', () => {
})
it('should record quadraticCurveTo()', () => {
})
it('should record rect()', () => {
})
it('should record closePath()', () => {
})
it('should record clip()', () => {
})
it('should record and commit clearRect()', () => {
})
it('should ignore createImageData()', () => {
})
it('should ignore createLinearGradient()', () => {
})
it('should ignore createPattern()', () => {
})
it('should ignore createRadialGradient()', () => {
})
it('should record and commit drawFocusIfNeeded()', () => {
})
it('should record and commit drawImage()', () => {
})
it('should record and commit fill()', () => {
})
it('should record and commit fillRect()', () => {
})
it('should record and commit fillText()', () => {
})
it('should ignore getImageData()', () => {
})
it('should ignore getLineDash()', () => {
})
it('should ignore isPointInPath()', () => {
})
it('should ignore isPointInStroke()', () => {
})
it('should ignore measureText()', () => {
})
it('should record and commit putImageData()', () => {
})
it('should record save()', () => {
})
it('should record rotate()', () => {
})
it('should record scale()', () => {
})
it('should record setLineDash()', () => {
})
it('should record setTransform()', () => {
})
it('should record and commit stroke()', () => {
})
it('should record and commit strokeRect()', () => {
})
it('should record and commit strokeText()', () => {
})
it('should record transform()', () => {
})
it('should record translate()', () => {
})
it('should record restore()', () => {
})
})
describe('disableUndo', () => {
it('should remove undo/redo functions', () => {
expect(context).to.respondTo('undo')
expect(context).to.respondTo('redo')
UndoCanvas.disableUndo(context)
expect(context).to.not.respondTo('undo')
expect(context).to.not.respondTo('redo')
})
})
})