Skip to content

Commit

Permalink
Move to arrow functions in the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
voxpelli committed Nov 5, 2016
1 parent 818c552 commit f40cb6e
Showing 1 changed file with 16 additions and 48 deletions.
64 changes: 16 additions & 48 deletions test/main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,10 @@ describe('Retry', function () {
});

return Promise.resolve()
.then(waitForCondition(function () {
return tryStub.callCount === 1 && retryStub.callCount === 1;
}))
.then(waitForCondition(function () {
return tryStub.callCount === 2 && retryStub.callCount === 2;
}))
.then(waitForCondition(function () {
return fulfilled === true;
}))
.then(function () {
return result;
});
.then(waitForCondition(() => tryStub.callCount === 1 && retryStub.callCount === 1))
.then(waitForCondition(() => tryStub.callCount === 2 && retryStub.callCount === 2))
.then(waitForCondition(() => fulfilled === true))
.then(() => result);
});

it('should work with default retry', function () {
Expand Down Expand Up @@ -213,9 +205,7 @@ describe('Retry', function () {
tryStub.resolves('abc123');

return retryInstance.try()
.then(function () {
return retryInstance.end();
})
.then(() => retryInstance.end())
.then(function () {
tryStub.should.have.been.calledOnce;
successSpy.should.have.been.calledOnce;
Expand All @@ -240,12 +230,8 @@ describe('Retry', function () {
let waitTicks = 30;

return Promise.resolve()
.then(waitForCondition(function () {
return tryStub.callCount === 1 && retryStub.callCount === 1 ? retryInstance.end() : false;
}))
.then(waitForCondition(function () {
return --waitTicks === 0;
}))
.then(waitForCondition(() => tryStub.callCount === 1 && retryStub.callCount === 1 ? retryInstance.end() : false))
.then(waitForCondition(() => --waitTicks === 0))
.then(function () {
tryStub.should.have.been.called;
retryStub.should.have.been.calledOnce;
Expand All @@ -263,9 +249,7 @@ describe('Retry', function () {
let waitTicks = 3;

return retryInstance.end()
.then(waitForCondition(function () {
return --waitTicks === 0;
}))
.then(waitForCondition(() => --waitTicks === 0))
.then(function () {
tryStub.should.not.have.been.called;
retryStub.should.not.have.been.called;
Expand All @@ -279,13 +263,9 @@ describe('Retry', function () {
tryStub.resolves('abc123');

return retryInstance.end()
.then(function () {
return retryInstance.try();
})
.then(() => retryInstance.try())
.then(
function () {
throw new Error('try() should not resolve after an ending');
},
() => Promise.reject(new Error('try() should not resolve after an ending')),
function () {
tryStub.should.not.have.been.called;
retryStub.should.not.have.been.called;
Expand Down Expand Up @@ -313,12 +293,8 @@ describe('Retry', function () {
});

return Promise.resolve()
.then(waitForCondition(function () {
return tryStub.callCount === 1 && retryStub.callCount === 1;
}))
.then(waitForCondition(function () {
return fulfilled === true;
}))
.then(waitForCondition(() => tryStub.callCount === 1 && retryStub.callCount === 1))
.then(waitForCondition(() => fulfilled === true))
.then(function () {
tryStub.should.have.been.calledTwice;
retryStub.should.have.been.calledTwice;
Expand Down Expand Up @@ -383,18 +359,10 @@ describe('Retry', function () {
});

return Promise.resolve()
.then(waitForCondition(function () {
return tryStub.callCount === 1 && retryStub.callCount === 1;
}))
.then(waitForCondition(function () {
return tryStub.callCount === 2;
}))
.then(waitForCondition(function () {
return fulfilled === true;
}))
.then(function () {
return result;
});
.then(waitForCondition(() => tryStub.callCount === 1 && retryStub.callCount === 1))
.then(waitForCondition(() => tryStub.callCount === 2))
.then(waitForCondition(() => fulfilled === true))
.then(() => result);
});
});
});

0 comments on commit f40cb6e

Please sign in to comment.