Migrated tests to jest
Used jest-codemods to migrate, will have to pass everything by hand before we can merge.
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
const throttle = (fn, wait) => {
|
||||
let inThrottle, lastFn, lastTime;
|
||||
return function() {
|
||||
const context = this,
|
||||
args = arguments;
|
||||
if (!inThrottle) {
|
||||
fn.apply(context, args);
|
||||
lastTime = Date.now();
|
||||
inThrottle = true;
|
||||
} else {
|
||||
clearTimeout(lastFn);
|
||||
lastFn = setTimeout(function() {
|
||||
if (Date.now() - lastTime >= wait) {
|
||||
fn.apply(context, args);
|
||||
lastTime = Date.now();
|
||||
}
|
||||
}, wait - (Date.now() - lastTime));
|
||||
}
|
||||
};
|
||||
};
|
||||
module.exports = throttle;
|
||||
@@ -1,14 +0,0 @@
|
||||
const test = require('tape');
|
||||
const throttle = require('./throttle.js');
|
||||
|
||||
test('Testing throttle', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof throttle === 'function', 'throttle is a Function');
|
||||
t.pass('Tested by @chalarangelo on 16/02/2018');
|
||||
//t.deepEqual(throttle(args..), 'Expected');
|
||||
//t.equal(throttle(args..), 'Expected');
|
||||
//t.false(throttle(args..), 'Expected');
|
||||
//t.throws(throttle(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
Reference in New Issue
Block a user