This is an automated email from the git hooks/post-receive script.
cohosh pushed a commit to branch main in repository pluggable-transports/snowflake-webext.
commit 1684bacfadf210a641c2c012c355c484e52e8d3d Author: David Fifield david@bamsoftware.com AuthorDate: Wed Mar 29 11:45:34 2023 -0600
Add a test for WS.makeWebsocketURL. --- spec/websocket.spec.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/spec/websocket.spec.js b/spec/websocket.spec.js new file mode 100644 index 0000000..a3c19c1 --- /dev/null +++ b/spec/websocket.spec.js @@ -0,0 +1,25 @@ +describe('makeWebsocketURL', function() { + it('attaches params', function() { + // With empty parameters, should leave input unchanged. + expect(WS.makeWebsocketURL('wss://example.com/path', []).toString()) + .toBe('wss://example.com/path'); + expect(WS.makeWebsocketURL('wss://example.com/path?client_ip=192.0.2.99', []).toString()) + .toBe('wss://example.com/path?client_ip=192.0.2.99'); + expect(WS.makeWebsocketURL('wss://example.com/path?client_ip=192.0.2.98&client_ip=192.0.2.99', []).toString()) + .toBe('wss://example.com/path?client_ip=192.0.2.98&client_ip=192.0.2.99'); + + // Should add new parameters. + expect(WS.makeWebsocketURL('wss://example.com/path', [['client_ip', '192.0.2.1']]).toString()) + .toBe('wss://example.com/path?client_ip=192.0.2.1'); + + // Should retain any other existing parameters. + expect(WS.makeWebsocketURL('wss://example.com/path?foo=bar', [['client_ip', '192.0.2.1']]).toString()) + .toBe('wss://example.com/path?foo=bar&client_ip=192.0.2.1'); + + // Should overwrite any existing parameters of the same name. + expect(WS.makeWebsocketURL('wss://example.com/path?client_ip=192.0.2.99', [['client_ip', '192.0.2.1']]).toString()) + .toBe('wss://example.com/path?client_ip=192.0.2.1'); + expect(WS.makeWebsocketURL('wss://example.com/path?client_ip=192.0.2.98&client_ip=192.0.2.99', [['client_ip', '192.0.2.1']]).toString()) + .toBe('wss://example.com/path?client_ip=192.0.2.1'); + }); +});