+ // Don't cache error (bug 65268)
+ api.getToken( 'testaction2' )
+ .fail( function ( err ) {
+ assert.equal( err, 'bite-me', 'Expected error' );
+ } )
+ .always( function () {
+ // Make this request after the first one has finished.
+ // If we make it simultaneously we still want it to share
+ // the cache, but as soon as it is fulfilled as error we
+ // reject it so that the next one tries fresh.
+ api.getToken( 'testaction2' )
+ .done( function ( token ) {
+ assert.ok( token.length, 'Got testaction2 token (error was not be cached)' );
+ } )
+ .fail( function ( err ) {
+ assert.equal( err, '', 'API error' );
+ } );
+
+ assert.equal( test.server.requests.length, 3, 'Requests made' );
+
+ test.server.requests[2].respond( 200, { 'Content-Type': 'application/json' },
+ '{ "tokens": { "testaction2token": "0123abc" } }'
+ );
+ } );