Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMike Gerwitz <gerwitm@lovullo.com>2015-05-27 15:26:03 -0400
committerMike Gerwitz <gerwitm@lovullo.com>2015-05-28 15:03:50 -0400
commit76280b0cac737d66d87cf93632ea952b359f4fd7 (patch)
treed1c7e9365dc321cdff732621111b64cb64cdd764 /test
parent2b92a2c4475ace2be2d164b3be2e67c30881926a (diff)
downloadliza-76280b0cac737d66d87cf93632ea952b359f4fd7.tar.gz
liza-76280b0cac737d66d87cf93632ea952b359f4fd7.tar.bz2
liza-76280b0cac737d66d87cf93632ea952b359f4fd7.zip
AutoRetry distinction between predicate truth and request failure
Diffstat (limited to 'test')
-rw-r--r--test/dapi/AutoRetryTest.js28
1 files changed, 17 insertions, 11 deletions
diff --git a/test/dapi/AutoRetryTest.js b/test/dapi/AutoRetryTest.js
index 8b10529..b9c6867 100644
--- a/test/dapi/AutoRetryTest.js
+++ b/test/dapi/AutoRetryTest.js
@@ -32,9 +32,9 @@ var _void = function() {},
describe( 'dapi.AutoRetry trait', function()
{
/**
- * If there are no failures, then AutoRetry has no observable effects.
+ * If there are no retries, then AutoRetry has no observable effects.
*/
- describe( 'when the request is successful', function()
+ describe( 'when the request does not need retrying', function()
{
it( 'makes only one request', function( done )
{
@@ -55,19 +55,25 @@ describe( 'dapi.AutoRetry trait', function()
} );
- it( 'returns the response data with no error', function( done )
+ /**
+ * We expect that any error will be proxied back to us; this is an
+ * important concept, since it allow separating the idea of a
+ * "retry" from that of a "failure": the latter represents a problem
+ * with the request, whereas the former indicates that a request
+ * should be performed once again.
+ */
+ it( 'returns the response data, including any error', function( done )
{
- var chk = { foo: 'bar' };
+ var chk = { foo: 'bar' },
+ chk_err = Error( 'foo' );
- // notice that we provide an error to the stub; this will ensure
- // that the returned error is null even when one is provided
- var stub = _createStub( {}, chk )
+ var stub = _createStub( chk_err, chk )
.use( Sut( _void, 1 ) )
();
stub.request( '', function( err, data )
{
- expect( err ).to.equal( null );
+ expect( err ).to.equal( chk_err );
expect( data ).to.equal( chk );
done();
} );
@@ -78,9 +84,9 @@ describe( 'dapi.AutoRetry trait', function()
/**
* This is when we care.
*/
- describe( 'when the request fails', function()
+ describe( 'when the retry predicate is true', function()
{
- it( 'will re-perform request N-1 times until failure', function( done )
+ it( 'will re-perform request N-1 times until false', function( done )
{
var n = 5;
@@ -207,7 +213,7 @@ describe( 'dapi.AutoRetry trait', function()
} );
- it( 'will call delay function until success', function()
+ it( 'will call delay function until predicate falsity', function()
{
var n = 5;
var wait = function( tries_left, c )