renovations

This commit is contained in:
Ilya Kantor 2015-01-14 10:23:45 +03:00
parent c7d4c7e3ff
commit e1948130f6
170 changed files with 1496 additions and 1161 deletions

View file

@ -0,0 +1,45 @@
describe("delay", function() {
before(function() {
this.clock = sinon.useFakeTimers();
});
after(function() {
this.clock.restore();
});
it("вызывает функцию через указанный таймаут", function() {
var start = Date.now();
function f(x) {
assert.equal(Date.now() - start, 1000);
}
f = sinon.spy(f);
var f1000 = delay(f, 1000);
f1000("test");
this.clock.tick(2000);
assert(f.calledOnce, 'calledOnce check fails');
});
it("передаёт аргументы и контекст", function() {
var start = Date.now();
var user = {
sayHi: function(phrase, who) {
assert.equal(this, user);
assert.equal(phrase, "Привет");
assert.equal(who, "Вася");
assert.equal(Date.now() - start, 1500);
}
};
user.sayHi = sinon.spy(user.sayHi);
var spy = user.sayHi;
user.sayHi = delay(user.sayHi, 1500);
user.sayHi("Привет", "Вася");
this.clock.tick(2000);
assert(spy.calledOnce, 'проверка calledOnce не сработала');
});
});