-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: convert 2 more test files to remove given and switch to TS (#882)
* chore: convert more given tests to TS * no given for toolbar tests * convert and fix toolbar tests
- Loading branch information
1 parent
3284071
commit 62d40fb
Showing
4 changed files
with
285 additions
and
289 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import RageClick from '../../extensions/rageclick' | ||
|
||
describe('RageClick()', () => { | ||
let instance: RageClick | ||
|
||
describe('when enabled', () => { | ||
beforeEach(() => { | ||
instance = new RageClick(true) | ||
}) | ||
|
||
it('identifies some rage clicking', () => { | ||
const detection = [ | ||
instance.isRageClick(0, 0, 10), | ||
instance.isRageClick(10, 10, 20), | ||
instance.isRageClick(5, 5, 40), // triggers rage click | ||
instance.isRageClick(5, 5, 50), // does not re-trigger | ||
] | ||
|
||
expect(detection).toEqual([false, false, true, false]) | ||
}) | ||
|
||
it('identifies some rage clicking when time delta has passed', () => { | ||
const detection = [ | ||
instance.isRageClick(0, 0, 10), | ||
instance.isRageClick(10, 10, 20), | ||
instance.isRageClick(5, 5, 40), // triggers rage click | ||
// these next three don't trigger | ||
// because you need to move past threshold before triggering again | ||
instance.isRageClick(5, 5, 80), | ||
instance.isRageClick(5, 5, 100), | ||
instance.isRageClick(5, 5, 110), | ||
// moving past the time threshold resets the counter | ||
instance.isRageClick(5, 5, 1120), | ||
instance.isRageClick(5, 5, 1121), | ||
instance.isRageClick(5, 5, 1122), // triggers rage click | ||
] | ||
|
||
expect(detection).toEqual([false, false, true, false, false, false, false, false, true]) | ||
}) | ||
|
||
it('identifies some rage clicking when pixel delta has passed', () => { | ||
const detection = [ | ||
instance.isRageClick(0, 0, 10), | ||
instance.isRageClick(10, 10, 20), | ||
instance.isRageClick(5, 5, 40), // triggers rage click | ||
// these next three don't trigger | ||
// because you need to move past threshold before triggering again | ||
instance.isRageClick(5, 5, 80), | ||
instance.isRageClick(5, 5, 100), | ||
instance.isRageClick(5, 5, 110), | ||
// moving past the pixel threshold resets the counter | ||
instance.isRageClick(36, 5, 120), | ||
instance.isRageClick(36, 5, 130), | ||
instance.isRageClick(36, 5, 140), // triggers rage click | ||
] | ||
|
||
expect(detection).toEqual([false, false, true, false, false, false, false, false, true]) | ||
}) | ||
|
||
it('does not capture clicks too far apart (time)', () => { | ||
instance.isRageClick(5, 5, 10) | ||
instance.isRageClick(5, 5, 20) | ||
const rageClickDetected = instance.isRageClick(5, 5, 4000) | ||
|
||
expect(rageClickDetected).toBeFalsy() | ||
}) | ||
|
||
it('does not capture clicks too far apart (space)', () => { | ||
instance.isRageClick(0, 0, 10) | ||
instance.isRageClick(10, 10, 20) | ||
const rageClickDetected = instance.isRageClick(50, 10, 40) | ||
|
||
expect(rageClickDetected).toBeFalsy() | ||
}) | ||
}) | ||
|
||
test('does not capture rage clicks when disabled', () => { | ||
instance = new RageClick(false) | ||
|
||
instance.isRageClick(5, 5, 10) | ||
instance.isRageClick(5, 5, 20) | ||
const rageClickDetected = instance.isRageClick(5, 5, 40) | ||
|
||
expect(rageClickDetected).toBeFalsy() | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.