mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
more explicit tests for debouncer wait and no-wait behavior
This commit is contained in:
parent
9bef4c057c
commit
8ef7bac6dc
@ -85,10 +85,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
};
|
||||
|
||||
window.el1.debounce('foo', cb);
|
||||
window.el1.debounce('foo', cb, 50);
|
||||
window.el1.debounce('foo', cb, 100);
|
||||
|
||||
setTimeout(function() {
|
||||
assert.equal(called, 1, 'debounce should be called exactly once');
|
||||
assert.equal(called, 0, 'callback is not called yet');
|
||||
}, 50);
|
||||
|
||||
setTimeout(function() {
|
||||
assert.equal(called, 1, 'callback was called exactly once');
|
||||
done();
|
||||
}, 200);
|
||||
|
||||
@ -140,7 +145,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
});
|
||||
|
||||
test('duplicate debouncer assignment', function(done) {
|
||||
test('duplicate debouncer assignment (no-wait)', function(done) {
|
||||
|
||||
var a, b;
|
||||
|
||||
@ -155,7 +160,26 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
assert.equal(a, undefined, 'first debouncer was never fired');
|
||||
assert.equal(b, 'bar', 'only the second debouncer callback was executed');
|
||||
done();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test('duplicate debouncer assignment (wait)', function(done) {
|
||||
|
||||
var a, b, delay = 50;
|
||||
|
||||
window.el1.debounce('foo', function() {
|
||||
a = 'foo';
|
||||
}, delay);
|
||||
window.el1.debounce('foo', function() {
|
||||
b = 'bar';
|
||||
}, delay);
|
||||
|
||||
setTimeout(function() {
|
||||
assert.equal(a, undefined, 'first debouncer was never fired');
|
||||
assert.equal(b, 'bar', 'only the second debouncer callback was executed');
|
||||
done();
|
||||
}, (delay+50));
|
||||
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user