forked from mistic100/Photo-Sphere-Viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPressHandler.spec.js
More file actions
32 lines (26 loc) · 774 Bytes
/
Copy pathPressHandler.spec.js
File metadata and controls
32 lines (26 loc) · 774 Bytes
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
import assert from 'assert';
import { PressHandler } from './PressHandler';
describe('utils:PressHandler', () => {
it('should wait at least X ms before exec', (done) => {
const handler = new PressHandler(100);
const start = new Date().getTime();
handler.down();
handler.up(() => {
const elapsed = new Date().getTime() - start;
assert.ok(elapsed >= 100);
done();
});
});
it('should exec immediately if X ms already elapsed', (done) => {
const handler = new PressHandler(100);
handler.down();
setTimeout(() => {
const start = new Date().getTime();
handler.up(() => {
const elapsed = new Date().getTime() - start;
assert.ok(elapsed < 5);
done();
});
}, 200);
});
});