11var expect = require ( 'chai' ) . expect ;
22var async = require ( 'async' ) ;
3- var ERROR_CODES = require ( '../../lib/error' ) . CODES ;
43
54module . exports = function ( ) {
65 describe ( 'client subscribe' , function ( ) {
@@ -47,7 +46,7 @@ module.exports = function() {
4746 } ) ;
4847
4948 function testSingleSnapshotSpecificError ( label , fns ) {
50- var createReadSnapshotsError = fns . createReadSnapshotsError ;
49+ var rejectSnapshot = fns . rejectSnapshot ;
5150 var verifyClientError = fns . verifyClientError ;
5251 it ( method + ' single with readSnapshots rejectSnapshotRead ' + label , function ( done ) {
5352 var backend = this . backend ;
@@ -59,7 +58,7 @@ module.exports = function() {
5958 backend . use ( 'readSnapshots' , function ( context , cb ) {
6059 expect ( context . snapshots ) . to . be . an ( 'array' ) . of . length ( 1 ) ;
6160 expect ( context . snapshots [ 0 ] ) . to . have . property ( 'id' , 'fido' ) ;
62- context . rejectSnapshotRead ( context . snapshots [ 0 ] , createReadSnapshotsError ( ) ) ;
61+ rejectSnapshot ( context , context . snapshots [ 0 ] ) ;
6362 cb ( ) ;
6463 } ) ;
6564
@@ -94,18 +93,16 @@ module.exports = function() {
9493 } ) ;
9594 }
9695 testSingleSnapshotSpecificError ( 'normal error' , {
97- createReadSnapshotsError : function ( ) {
98- return new Error ( 'Failed to fetch fido' ) ;
96+ rejectSnapshot : function ( context , snapshot ) {
97+ context . rejectSnapshotRead ( snapshot , new Error ( 'Failed to fetch fido' ) ) ;
9998 } ,
10099 verifyClientError : function ( err ) {
101100 expect ( err ) . to . be . an ( 'error' ) . with . property ( 'message' , 'Failed to fetch fido' ) ;
102101 }
103102 } ) ;
104- testSingleSnapshotSpecificError ( 'special ignorable error' , {
105- createReadSnapshotsError : function ( ) {
106- var err = new Error ( 'Failed to fetch fido' ) ;
107- err . code = ERROR_CODES . ERR_SNAPSHOT_READ_SILENT_REJECTION ;
108- return err ;
103+ testSingleSnapshotSpecificError ( 'silent error' , {
104+ rejectSnapshot : function ( context , snapshot ) {
105+ context . rejectSnapshotReadSilent ( snapshot , 'Failed to fetch fido' ) ;
109106 } ,
110107 verifyClientError : function ( err ) {
111108 expect ( err ) . to . equal ( undefined ) ;
@@ -222,7 +219,7 @@ module.exports = function() {
222219 } ) ;
223220
224221 function testBulkSnapshotSpecificError ( label , fns ) {
225- var createReadSnapshotsError = fns . createReadSnapshotsError ;
222+ var rejectSnapshot = fns . rejectSnapshot ;
226223 var verifyClientError = fns . verifyClientError ;
227224 it ( method + ' bulk with readSnapshots rejectSnapshotRead ' + label , function ( done ) {
228225 var backend = this . backend ;
@@ -241,7 +238,7 @@ module.exports = function() {
241238 backend . use ( 'readSnapshots' , function ( context , cb ) {
242239 expect ( context . snapshots ) . to . be . an ( 'array' ) . of . length ( 2 ) ;
243240 expect ( context . snapshots [ 0 ] ) . to . have . property ( 'id' , 'fido' ) ;
244- context . rejectSnapshotRead ( context . snapshots [ 0 ] , createReadSnapshotsError ( ) ) ;
241+ rejectSnapshot ( context , context . snapshots [ 0 ] ) ;
245242 cb ( ) ;
246243 } ) ;
247244
@@ -294,18 +291,16 @@ module.exports = function() {
294291 } ) ;
295292 }
296293 testBulkSnapshotSpecificError ( 'normal error' , {
297- createReadSnapshotsError : function ( ) {
298- return new Error ( 'Failed to fetch fido' ) ;
294+ rejectSnapshot : function ( context , snapshot ) {
295+ context . rejectSnapshotRead ( snapshot , new Error ( 'Failed to fetch fido' ) ) ;
299296 } ,
300297 verifyClientError : function ( err ) {
301298 expect ( err ) . to . be . an ( 'error' ) . with . property ( 'message' , 'Failed to fetch fido' ) ;
302299 }
303300 } ) ;
304301 testBulkSnapshotSpecificError ( 'special ignorable error' , {
305- createReadSnapshotsError : function ( ) {
306- var err = new Error ( 'Failed to fetch fido' ) ;
307- err . code = ERROR_CODES . ERR_SNAPSHOT_READ_SILENT_REJECTION ;
308- return err ;
302+ rejectSnapshot : function ( context , snapshot ) {
303+ context . rejectSnapshotReadSilent ( snapshot , 'Failed to fetch fido' ) ;
309304 } ,
310305 verifyClientError : function ( err ) {
311306 expect ( err ) . to . equal ( undefined ) ;
0 commit comments