q5 2.10.7 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/deno.json +36 -0
- package/package.json +3 -6
- package/q5-deno-server.js +45 -0
- package/q5-server.js +6 -7
- package/q5.js +19 -13
- package/q5.min.js +2 -2
- package/src/q5-2d-image.js +1 -1
- package/src/q5-canvas.js +16 -10
- package/src/q5-core.js +2 -2
- package/test/core.test.js +30 -0
- package/test/readme.md +5 -0
- package/.vscode/launch.json +0 -26
- package/.vscode/settings.json +0 -3
- package/bun.lockb +0 -0
- package/p5-tests/js/chai_helpers.js +0 -20
- package/p5-tests/js/mocha_setup.js +0 -2
- package/p5-tests/js/modernizr.js +0 -5
- package/p5-tests/js/p5_helpers.js +0 -135
- package/p5-tests/js/sinon.js +0 -5949
- package/p5-tests/mocha.css +0 -289
- package/p5-tests/test.html +0 -71
- package/p5-tests/unit/color/color_conversion.js +0 -68
- package/p5-tests/unit/color/creating_reading.js +0 -217
- package/p5-tests/unit/color/p5.Color.js +0 -1000
- package/p5-tests/unit/color/setting.js +0 -289
- package/p5-tests/unit/core/2d_primitives.js +0 -490
- package/p5-tests/unit/core/attributes.js +0 -115
- package/p5-tests/unit/core/curves.js +0 -139
- package/p5-tests/unit/core/environment.js +0 -248
- package/p5-tests/unit/core/error_helpers.js +0 -1158
- package/p5-tests/unit/core/main.js +0 -340
- package/p5-tests/unit/core/p5.Element.js +0 -773
- package/p5-tests/unit/core/p5.Graphics.js +0 -179
- package/p5-tests/unit/core/preload.js +0 -285
- package/p5-tests/unit/core/rendering.js +0 -116
- package/p5-tests/unit/core/structure.js +0 -293
- package/p5-tests/unit/core/transform.js +0 -144
- package/p5-tests/unit/core/version.js +0 -28
- package/p5-tests/unit/core/vertex.js +0 -137
- package/p5-tests/unit/dom/dom.js +0 -2146
- package/p5-tests/unit/events/acceleration.js +0 -213
- package/p5-tests/unit/events/keyboard.js +0 -179
- package/p5-tests/unit/events/mouse.js +0 -487
- package/p5-tests/unit/events/touch.js +0 -180
- package/p5-tests/unit/image/downloading.js +0 -379
- package/p5-tests/unit/image/filters.js +0 -92
- package/p5-tests/unit/image/loading.js +0 -413
- package/p5-tests/unit/image/p5.Image.js +0 -201
- package/p5-tests/unit/image/pixels.js +0 -234
- package/p5-tests/unit/io/files.js +0 -378
- package/p5-tests/unit/io/loadBytes.js +0 -149
- package/p5-tests/unit/io/loadImage.js +0 -123
- package/p5-tests/unit/io/loadJSON.js +0 -185
- package/p5-tests/unit/io/loadModel.js +0 -215
- package/p5-tests/unit/io/loadShader.js +0 -176
- package/p5-tests/unit/io/loadStrings.js +0 -140
- package/p5-tests/unit/io/loadTable.js +0 -183
- package/p5-tests/unit/io/loadXML.js +0 -127
- package/p5-tests/unit/io/saveModel.js +0 -113
- package/p5-tests/unit/io/saveTable.js +0 -142
- package/p5-tests/unit/math/calculation.js +0 -452
- package/p5-tests/unit/math/noise.js +0 -66
- package/p5-tests/unit/math/p5.Vector.js +0 -1886
- package/p5-tests/unit/math/random.js +0 -177
- package/p5-tests/unit/math/trigonometry.js +0 -144
- package/p5-tests/unit/spec.js +0 -50
- package/p5-tests/unit/typography/attributes.js +0 -120
- package/p5-tests/unit/typography/loadFont.js +0 -162
- package/p5-tests/unit/typography/p5.Font.js +0 -63
- package/p5-tests/unit/utilities/conversion.js +0 -329
- package/p5-tests/unit/utilities/time_date.js +0 -133
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
suite('Acceleration Events', function() {
|
|
2
|
-
var myp5;
|
|
3
|
-
setup(function(done) {
|
|
4
|
-
new p5(function(p) {
|
|
5
|
-
p.setup = function() {
|
|
6
|
-
myp5 = p;
|
|
7
|
-
done();
|
|
8
|
-
};
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
teardown(function() {
|
|
13
|
-
myp5.remove();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
let deviceMotionEvent1 = new DeviceMotionEvent('devicemotion', {
|
|
17
|
-
acceleration: { x: 10, y: 20, z: 30 }
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
let deviceMotionEvent2 = new DeviceMotionEvent('devicemotion', {
|
|
21
|
-
acceleration: { x: 20, y: 40, z: 10 }
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
let deviceOrientationEvent1 = new DeviceOrientationEvent(
|
|
25
|
-
'deviceorientation',
|
|
26
|
-
{
|
|
27
|
-
alpha: 10,
|
|
28
|
-
beta: 45,
|
|
29
|
-
gamma: 90
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
let deviceOrientationEvent2 = new DeviceOrientationEvent(
|
|
34
|
-
'deviceorientation',
|
|
35
|
-
{
|
|
36
|
-
alpha: 15,
|
|
37
|
-
beta: 30,
|
|
38
|
-
gamma: 180
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
suite('acceleration', function() {
|
|
43
|
-
test('accelerationX should be 20', function() {
|
|
44
|
-
window.dispatchEvent(deviceMotionEvent1);
|
|
45
|
-
assert.strictEqual(myp5.accelerationX, 20);
|
|
46
|
-
});
|
|
47
|
-
test('accelerationY should be 40', function() {
|
|
48
|
-
window.dispatchEvent(deviceMotionEvent1);
|
|
49
|
-
assert.strictEqual(myp5.accelerationY, 40);
|
|
50
|
-
});
|
|
51
|
-
test('accelerationZ should be 60', function() {
|
|
52
|
-
window.dispatchEvent(deviceMotionEvent1);
|
|
53
|
-
assert.strictEqual(myp5.accelerationZ, 60);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
suite('previous acceleration', function() {
|
|
58
|
-
test('pAccelerationX should be 20', function() {
|
|
59
|
-
window.dispatchEvent(deviceMotionEvent1);
|
|
60
|
-
window.dispatchEvent(deviceMotionEvent2);
|
|
61
|
-
assert.strictEqual(myp5.pAccelerationX, 20);
|
|
62
|
-
});
|
|
63
|
-
test('pAccelerationY should be 40', function() {
|
|
64
|
-
window.dispatchEvent(deviceMotionEvent1);
|
|
65
|
-
window.dispatchEvent(deviceMotionEvent2);
|
|
66
|
-
assert.strictEqual(myp5.pAccelerationY, 40);
|
|
67
|
-
});
|
|
68
|
-
test('pAccelerationZ should be 60', function() {
|
|
69
|
-
window.dispatchEvent(deviceMotionEvent1);
|
|
70
|
-
window.dispatchEvent(deviceMotionEvent2);
|
|
71
|
-
assert.strictEqual(myp5.pAccelerationZ, 60);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
suite('rotation', function() {
|
|
76
|
-
test('rotationX should be 45', function() {
|
|
77
|
-
window.dispatchEvent(deviceOrientationEvent1);
|
|
78
|
-
assert.strictEqual(myp5.rotationX, 45 * (Math.PI / 180.0));
|
|
79
|
-
});
|
|
80
|
-
test('rotationY should be 90', function() {
|
|
81
|
-
window.dispatchEvent(deviceOrientationEvent1);
|
|
82
|
-
assert.strictEqual(myp5.rotationY, 90 * (Math.PI / 180.0));
|
|
83
|
-
});
|
|
84
|
-
test('rotationZ should be 10', function() {
|
|
85
|
-
window.dispatchEvent(deviceOrientationEvent1);
|
|
86
|
-
assert.strictEqual(myp5.rotationZ, 10 * (Math.PI / 180.0));
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
suite('previous rotation', function() {
|
|
91
|
-
test('pRotationX should be 45', function() {
|
|
92
|
-
window.dispatchEvent(deviceOrientationEvent1);
|
|
93
|
-
window.dispatchEvent(deviceOrientationEvent2);
|
|
94
|
-
assert.strictEqual(myp5.pRotationX, 45 * (Math.PI / 180.0));
|
|
95
|
-
});
|
|
96
|
-
test('pRotationY should be 90', function() {
|
|
97
|
-
window.dispatchEvent(deviceOrientationEvent1);
|
|
98
|
-
window.dispatchEvent(deviceOrientationEvent2);
|
|
99
|
-
assert.strictEqual(myp5.pRotationY, 90 * (Math.PI / 180.0));
|
|
100
|
-
});
|
|
101
|
-
test('pRotationZ should be 10', function() {
|
|
102
|
-
window.dispatchEvent(deviceOrientationEvent1);
|
|
103
|
-
window.dispatchEvent(deviceOrientationEvent2);
|
|
104
|
-
assert.strictEqual(myp5.pRotationZ, 10 * (Math.PI / 180.0));
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
suite('deviceMoved', function() {
|
|
109
|
-
test('deviceMoved must run when device is moved more than the threshold value', function() {
|
|
110
|
-
let count = 0;
|
|
111
|
-
myp5.deviceMoved = function() {
|
|
112
|
-
count += 1;
|
|
113
|
-
};
|
|
114
|
-
window.dispatchEvent(
|
|
115
|
-
new DeviceMotionEvent('devicemotion', { acceleration: { x: 10 } })
|
|
116
|
-
);
|
|
117
|
-
assert.strictEqual(count, 1);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
test('deviceMoved should not run when device is moved less than the threshold value', function() {
|
|
121
|
-
let count = 0;
|
|
122
|
-
myp5.deviceMoved = function() {
|
|
123
|
-
count += 1;
|
|
124
|
-
};
|
|
125
|
-
window.dispatchEvent(
|
|
126
|
-
new DeviceMotionEvent('devicemotion', { acceleration: { x: 0.1 } })
|
|
127
|
-
);
|
|
128
|
-
//deviceMoved should not run since move threshold is by default 0.5
|
|
129
|
-
assert.strictEqual(count, 0);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
test('p5.prototype.setMoveThreshold', function() {
|
|
133
|
-
let count = 0;
|
|
134
|
-
myp5.deviceMoved = function() {
|
|
135
|
-
count += 1;
|
|
136
|
-
};
|
|
137
|
-
myp5.setMoveThreshold(0.1);
|
|
138
|
-
window.dispatchEvent(
|
|
139
|
-
new DeviceMotionEvent('devicemotion', { acceleration: { x: 0.1 } })
|
|
140
|
-
);
|
|
141
|
-
//deviceMoved should run since move threshold is set to 0.1 now
|
|
142
|
-
assert.strictEqual(count, 1);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
suite('deviceTurned', function() {
|
|
147
|
-
test('deviceTurned must run when device is turned more than 90 degrees', function() {
|
|
148
|
-
let count = 0;
|
|
149
|
-
myp5.deviceTurned = function() {
|
|
150
|
-
count += 1;
|
|
151
|
-
};
|
|
152
|
-
window.dispatchEvent(
|
|
153
|
-
new DeviceOrientationEvent('deviceorientation', { beta: 5 })
|
|
154
|
-
);
|
|
155
|
-
window.dispatchEvent(
|
|
156
|
-
new DeviceOrientationEvent('deviceorientation', { beta: 100 })
|
|
157
|
-
);
|
|
158
|
-
assert.strictEqual(count, 1);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
test('turnAxis should be X', function() {
|
|
162
|
-
let count = 0;
|
|
163
|
-
myp5.deviceTurned = function() {
|
|
164
|
-
if (myp5.turnAxis === 'X') count += 1;
|
|
165
|
-
};
|
|
166
|
-
window.dispatchEvent(
|
|
167
|
-
new DeviceOrientationEvent('deviceorientation', { beta: 5 })
|
|
168
|
-
);
|
|
169
|
-
window.dispatchEvent(
|
|
170
|
-
new DeviceOrientationEvent('deviceorientation', { beta: 100 })
|
|
171
|
-
);
|
|
172
|
-
assert.strictEqual(count, 1);
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
suite('deviceShaken', function() {
|
|
177
|
-
test('deviceShaken must run when device acceleration is more than the threshold value', function() {
|
|
178
|
-
let count = 0;
|
|
179
|
-
myp5.deviceShaken = function() {
|
|
180
|
-
count += 1;
|
|
181
|
-
};
|
|
182
|
-
window.dispatchEvent(
|
|
183
|
-
new DeviceMotionEvent('devicemotion', { acceleration: { x: 5, y: 15 } })
|
|
184
|
-
);
|
|
185
|
-
assert.strictEqual(count, 1);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
test('deviceMoved should not run when device acceleration is less than the threshold value', function() {
|
|
189
|
-
let count = 0;
|
|
190
|
-
myp5.deviceShaken = function() {
|
|
191
|
-
count += 1;
|
|
192
|
-
};
|
|
193
|
-
window.dispatchEvent(
|
|
194
|
-
new DeviceMotionEvent('devicemotion', { acceleration: { x: 10 } })
|
|
195
|
-
);
|
|
196
|
-
//deviceMoved should not run since shake threshold is by default 30
|
|
197
|
-
assert.strictEqual(count, 0);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
test('p5.prototype.setShakeThreshold', function() {
|
|
201
|
-
let count = 0;
|
|
202
|
-
myp5.deviceShaken = function() {
|
|
203
|
-
count += 1;
|
|
204
|
-
};
|
|
205
|
-
myp5.setShakeThreshold(10);
|
|
206
|
-
window.dispatchEvent(
|
|
207
|
-
new DeviceMotionEvent('devicemotion', { acceleration: { x: 10 } })
|
|
208
|
-
);
|
|
209
|
-
//deviceMoved should run since shake threshold is set to 10 now
|
|
210
|
-
assert.strictEqual(count, 1);
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
});
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
suite('Keyboard Events', function() {
|
|
2
|
-
var myp5;
|
|
3
|
-
|
|
4
|
-
setup(function(done) {
|
|
5
|
-
new p5(function(p) {
|
|
6
|
-
p.setup = function() {
|
|
7
|
-
myp5 = p;
|
|
8
|
-
done();
|
|
9
|
-
};
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
teardown(function() {
|
|
14
|
-
myp5.remove();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
suite('p5.prototype.keyIsPressed', function() {
|
|
18
|
-
test('keyIsPressed should be a boolean', function() {
|
|
19
|
-
assert.isBoolean(myp5.keyIsPressed);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('keyIsPressed should be true on key press', function() {
|
|
23
|
-
window.dispatchEvent(new KeyboardEvent('keydown'));
|
|
24
|
-
assert.strictEqual(myp5.keyIsPressed, true);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('keyIsPressed should be true on multiple key presses', function() {
|
|
28
|
-
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
|
|
29
|
-
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Down' }));
|
|
30
|
-
assert.strictEqual(myp5.keyIsPressed, true);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('keyIsPressed should be false on key up', function() {
|
|
34
|
-
window.dispatchEvent(new KeyboardEvent('keyup'));
|
|
35
|
-
assert.strictEqual(myp5.keyIsPressed, false);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
suite('p5.prototype.key', function() {
|
|
40
|
-
test('key should be a string', function() {
|
|
41
|
-
window.dispatchEvent(new KeyboardEvent('keydown', { key: 's' }));
|
|
42
|
-
assert.isString(myp5.key);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('key should return the key pressed', function() {
|
|
46
|
-
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'A' }));
|
|
47
|
-
assert.strictEqual(myp5.key, 'A');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('key should return the key pressed', function() {
|
|
51
|
-
window.dispatchEvent(new KeyboardEvent('keydown', { key: '9' }));
|
|
52
|
-
assert.strictEqual(myp5.key, '9');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('key should return the key pressed', function() {
|
|
56
|
-
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'CapsLock' }));
|
|
57
|
-
assert.strictEqual(myp5.key, 'CapsLock');
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
suite('p5.prototype.keyCode', function() {
|
|
62
|
-
test('keyCode should be a number', function() {
|
|
63
|
-
window.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 65 }));
|
|
64
|
-
assert.isNumber(myp5.keyCode);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test('key should return the key pressed', function() {
|
|
68
|
-
window.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 65 }));
|
|
69
|
-
assert.strictEqual(myp5.keyCode, 65);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
suite('keyPressed', function() {
|
|
74
|
-
test('keyPressed must run when key is pressed', function() {
|
|
75
|
-
let count = 0;
|
|
76
|
-
myp5.keyPressed = function() {
|
|
77
|
-
count += 1;
|
|
78
|
-
};
|
|
79
|
-
window.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 65 }));
|
|
80
|
-
window.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 35 }));
|
|
81
|
-
assert.strictEqual(count, 2);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test('keyPressed functions on multiple instances must run once', async function() {
|
|
85
|
-
let sketchFn = function(sketch, resolve, reject) {
|
|
86
|
-
let count = 0;
|
|
87
|
-
sketch.keyPressed = function() {
|
|
88
|
-
count += 1;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
sketch.finish = function() {
|
|
92
|
-
resolve(count);
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
let sketches = parallelSketches([sketchFn, sketchFn]); //create two sketches
|
|
96
|
-
await sketches.setup; //wait for all sketches to setup
|
|
97
|
-
window.dispatchEvent(new KeyboardEvent('keydown')); //dispatch a keyboard event to trigger the keyPressed functions
|
|
98
|
-
sketches.end(); //resolve all sketches by calling their finish functions
|
|
99
|
-
let counts = await sketches.result; //get array holding number of times keyPressed was called. Rejected sketches also thrown here
|
|
100
|
-
assert.deepEqual(counts, [1, 1]); //check if every keyPressed function was called once
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
suite('keyReleased', function() {
|
|
105
|
-
test('keyReleased must run when key is released', function() {
|
|
106
|
-
let count = 0;
|
|
107
|
-
myp5.keyReleased = function() {
|
|
108
|
-
count += 1;
|
|
109
|
-
};
|
|
110
|
-
window.dispatchEvent(new KeyboardEvent('keyup'));
|
|
111
|
-
assert.strictEqual(count, 1);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
test('keyReleased functions on multiple instances must run once', async function() {
|
|
115
|
-
let sketchFn = function(sketch, resolve, reject) {
|
|
116
|
-
let count = 0;
|
|
117
|
-
|
|
118
|
-
sketch.keyReleased = function() {
|
|
119
|
-
count += 1;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
sketch.finish = function() {
|
|
123
|
-
resolve(count);
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
let sketches = parallelSketches([sketchFn, sketchFn]); //create two sketches
|
|
127
|
-
await sketches.setup; //wait for all sketches to setup
|
|
128
|
-
window.dispatchEvent(new KeyboardEvent('keyup')); //dispatch a keyboard event to trigger the keyReleased functions
|
|
129
|
-
sketches.end(); //resolve all sketches by calling their finish functions
|
|
130
|
-
let counts = await sketches.result; //get array holding number of times keyPressed was called. Rejected sketches also thrown here
|
|
131
|
-
assert.deepEqual(counts, [1, 1]); //check if every keyPressed function was called once
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
suite('keyTyped', function() {
|
|
136
|
-
test('keyTyped must run when key is pressed', function() {
|
|
137
|
-
let count = 0;
|
|
138
|
-
myp5.keyTyped = function() {
|
|
139
|
-
count += 1;
|
|
140
|
-
};
|
|
141
|
-
window.dispatchEvent(new KeyboardEvent('keypress'));
|
|
142
|
-
assert.strictEqual(count, 1);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test('keyTyped functions on multiple instances must run once', async function() {
|
|
146
|
-
let sketchFn = function(sketch, resolve, reject) {
|
|
147
|
-
let count = 0;
|
|
148
|
-
sketch.keyTyped = function() {
|
|
149
|
-
count += 1;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
sketch.finish = function() {
|
|
153
|
-
resolve(count);
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
let sketches = parallelSketches([sketchFn, sketchFn]); //create two sketches
|
|
157
|
-
await sketches.setup; //wait for all sketches to setup
|
|
158
|
-
window.dispatchEvent(new KeyboardEvent('keypress', { key: 'A' })); //dispatch a keyboard event to trigger the keyTyped functions
|
|
159
|
-
sketches.end(); //resolve all sketches by calling their finish functions
|
|
160
|
-
let counts = await sketches.result; //get array holding number of times keyPressed was called. Rejected sketches also thrown here
|
|
161
|
-
assert.deepEqual(counts, [1, 1]); //check if every keyPressed function was called once
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
suite('p5.prototype.keyIsDown', function() {
|
|
166
|
-
test('keyIsDown should return a boolean', function() {
|
|
167
|
-
assert.isBoolean(myp5.keyIsDown(65));
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
test('keyIsDown should return true if key is down', function() {
|
|
171
|
-
window.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 35 }));
|
|
172
|
-
assert.strictEqual(myp5.keyIsDown(35), true);
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
test('keyIsDown should return false if key is not down', function() {
|
|
176
|
-
assert.strictEqual(myp5.keyIsDown(35), false);
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
});
|