Skip to content

Instantly share code, notes, and snippets.

@beaucollins
Created September 23, 2019 21:36
Show Gist options
  • Select an option

  • Save beaucollins/019131c0623a8ea49e2e5c1c905f7aed to your computer and use it in GitHub Desktop.

Select an option

Save beaucollins/019131c0623a8ea49e2e5c1c905f7aed to your computer and use it in GitHub Desktop.
diff --git a/test/simperium/channel_test.js b/test/simperium/channel_test.js
index 0db6fae..d409aba 100644
--- a/test/simperium/channel_test.js
+++ b/test/simperium/channel_test.js
@@ -437,6 +437,30 @@ describe( 'Channel', function() {
done()
} );
} );
+
+ it( 'should handle a 409', ( done ) =>{
+ channel.localQueue.sent['mock-id'] = { fake: 'change', ccid: 'dup-ccid' }
+
+ /**
+ * If the 409 is not handled the bucket will error
+ */
+ bucket.once( 'error', ( e ) => {
+ done( e );
+ } );
+
+ /**
+ * After successfully handling the 409 we should have an acknowledged
+ * local change.
+ */
+ channel.once( 'acknowledge', ( id, change ) => {
+ done();
+ } );
+
+ /**
+ * Simulate receiving a 409
+ */
+ channel.handleMessage( 'c:[{"error": 409, "ccid":"dup-ccid", "id": "mock-id"}]' );
+ } );
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment