Added some tests
This commit is contained in:
10
test/debounce/debounce.js
Normal file
10
test/debounce/debounce.js
Normal file
@ -0,0 +1,10 @@
|
||||
const debounce = (fn, wait = 0) => {
|
||||
let inDebounce;
|
||||
return function() {
|
||||
const context = this,
|
||||
args = arguments;
|
||||
clearTimeout(inDebounce);
|
||||
inDebounce = setTimeout(() => fn.apply(context, args), wait);
|
||||
};
|
||||
};
|
||||
module.exports = debounce
|
||||
13
test/debounce/debounce.test.js
Normal file
13
test/debounce/debounce.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const debounce = require('./debounce.js');
|
||||
|
||||
test('Testing debounce', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof debounce === 'function', 'debounce is a Function');
|
||||
//t.deepEqual(debounce(args..), 'Expected');
|
||||
//t.equal(debounce(args..), 'Expected');
|
||||
//t.false(debounce(args..), 'Expected');
|
||||
//t.throws(debounce(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
Reference in New Issue
Block a user