@@ -214,6 +214,15 @@ describe('SnapshotRequest', function () {
214214 it ( 'can drop its connection and reconnect, and the callback is just called once' , function ( done ) {
215215 var connection = backend . connect ( ) ;
216216
217+ // Here we hook into middleware to make sure that we get the following flow:
218+ // - Connection established
219+ // - Connection attempts to fetch a snapshot
220+ // - Snapshot is about to be returned
221+ // - Connection is dropped before the snapshot is returned
222+ // - Connection is re-established
223+ // - Connection re-requests the snapshot
224+ // - This time the fetch operation is allowed to complete (because of the connectionInterrupted flag)
225+ // - The done callback is called just once (if it's called twice, then mocha will complain)
217226 var connectionInterrupted = false ;
218227 backend . use ( backend . MIDDLEWARE_ACTIONS . readSnapshots , function ( request , callback ) {
219228 if ( ! connectionInterrupted ) {
@@ -231,6 +240,13 @@ describe('SnapshotRequest', function () {
231240 it ( 'cannot send the same request twice over a connection' , function ( done ) {
232241 var connection = backend . connect ( ) ;
233242
243+ // Here we hook into the middleware to make sure that we get the following flow:
244+ // - Attempt to fetch a snapshot
245+ // - The snapshot request is temporarily stored on the Connection
246+ // - Snapshot is about to be returned (ie the request was already successfully sent)
247+ // - We attempt to resend the request again
248+ // - The done callback is call just once, because the second request does not get sent
249+ // (if the done callback is called twice, then mocha will complain)
234250 var hasResent = false ;
235251 backend . use ( backend . MIDDLEWARE_ACTIONS . readSnapshots , function ( request , callback ) {
236252 if ( ! hasResent ) {
0 commit comments