forked from anotherso1a/spadger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4f7f0b
commit 062d3cc
Showing
5 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
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
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,20 @@ | ||
import { throttle } from '../../src/function/throttle'; | ||
// import { debounce} from "../../src/function/debounce"; | ||
|
||
test('throttle', () => { | ||
let count: Number = 0; | ||
let fn = n => n++; | ||
let throttled = throttle(fn, 20); | ||
for (let i = 0; i < 5; i++) { | ||
setTimeout(() => { | ||
throttled(count); | ||
expect(count).toBe(i + 1); | ||
}, i * 21); | ||
} | ||
for (let i = 0; i < 2; i++) { | ||
setTimeout(() => { | ||
throttled(count); | ||
expect(count).toBe(1); | ||
}, i * 9); | ||
} | ||
}); |
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,5 @@ | ||
import { object2map } from '../../src/object/object2map'; | ||
|
||
test('object2map {a:1,b:2} will returns a Map', () => { | ||
expect(object2map({ a: 1, b: 2 }).size).toBe(2); | ||
}); |
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,11 @@ | ||
import { parseQuery } from '../../src/string/parseQuery'; | ||
import { stringifyQuery } from '../../src/string/stringifyQuery'; | ||
|
||
test('parseQuery "a=1&b=2" returns an object', () => { | ||
expect(JSON.stringify(parseQuery('a=1&b=2'))).toBe( | ||
JSON.stringify({ a: '1', b: '2' }) | ||
); | ||
}); | ||
test('stringifyQuery "{a:1,b:2}" returns an string', () => { | ||
expect(stringifyQuery({ a: 1, b: 2 })).toBe('a=1&b=2'); | ||
}); |
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