2019-07-07 15:40:51 +02:00
|
|
|
/* global expect, it, describe, WS */
|
|
|
|
|
|
2019-07-06 15:13:06 +02:00
|
|
|
/*
|
|
|
|
|
jasmine tests for Snowflake websocket
|
|
|
|
|
*/
|
2019-07-06 15:20:07 +02:00
|
|
|
|
2019-07-06 15:13:06 +02:00
|
|
|
describe('BuildUrl', function() {
|
2019-07-06 15:20:07 +02:00
|
|
|
|
2019-07-06 15:13:06 +02:00
|
|
|
it('should parse just protocol and host', function() {
|
2019-07-06 15:20:07 +02:00
|
|
|
expect(WS.buildUrl('http', 'example.com')).toBe('http://example.com');
|
2019-07-06 15:13:06 +02:00
|
|
|
});
|
2019-07-06 15:20:07 +02:00
|
|
|
|
2019-07-06 15:13:06 +02:00
|
|
|
it('should handle different ports', function() {
|
|
|
|
|
expect(WS.buildUrl('http', 'example.com', 80)).toBe('http://example.com');
|
|
|
|
|
expect(WS.buildUrl('http', 'example.com', 81)).toBe('http://example.com:81');
|
|
|
|
|
expect(WS.buildUrl('http', 'example.com', 443)).toBe('http://example.com:443');
|
2019-07-06 15:20:07 +02:00
|
|
|
expect(WS.buildUrl('http', 'example.com', 444)).toBe('http://example.com:444');
|
2019-07-06 15:13:06 +02:00
|
|
|
});
|
2019-07-06 15:20:07 +02:00
|
|
|
|
2019-07-06 15:13:06 +02:00
|
|
|
it('should handle paths', function() {
|
|
|
|
|
expect(WS.buildUrl('http', 'example.com', 80, '/')).toBe('http://example.com/');
|
|
|
|
|
expect(WS.buildUrl('http', 'example.com', 80, '/test?k=%#v')).toBe('http://example.com/test%3Fk%3D%25%23v');
|
2019-07-06 15:20:07 +02:00
|
|
|
expect(WS.buildUrl('http', 'example.com', 80, '/test')).toBe('http://example.com/test');
|
2019-07-06 15:13:06 +02:00
|
|
|
});
|
2019-07-06 15:20:07 +02:00
|
|
|
|
2019-07-06 15:13:06 +02:00
|
|
|
it('should handle params', function() {
|
|
|
|
|
expect(WS.buildUrl('http', 'example.com', 80, '/test', [['k', '%#v']])).toBe('http://example.com/test?k=%25%23v');
|
2019-07-06 15:20:07 +02:00
|
|
|
expect(WS.buildUrl('http', 'example.com', 80, '/test', [['a', 'b'], ['c', 'd']])).toBe('http://example.com/test?a=b&c=d');
|
2019-07-06 15:13:06 +02:00
|
|
|
});
|
2019-07-06 15:20:07 +02:00
|
|
|
|
2019-07-06 15:13:06 +02:00
|
|
|
it('should handle ips', function() {
|
|
|
|
|
expect(WS.buildUrl('http', '1.2.3.4')).toBe('http://1.2.3.4');
|
2019-07-06 15:20:07 +02:00
|
|
|
expect(WS.buildUrl('http', '1:2::3:4')).toBe('http://[1:2::3:4]');
|
2019-07-06 15:13:06 +02:00
|
|
|
});
|
2019-07-06 15:20:07 +02:00
|
|
|
|
|
|
|
|
it('should handle bogus', function() {
|
2019-07-06 15:13:06 +02:00
|
|
|
expect(WS.buildUrl('http', 'bog][us')).toBe('http://bog%5D%5Bus');
|
2019-07-06 15:20:07 +02:00
|
|
|
expect(WS.buildUrl('http', 'bog:u]s')).toBe('http://bog%3Au%5Ds');
|
2019-07-06 15:13:06 +02:00
|
|
|
});
|
2019-07-06 15:20:07 +02:00
|
|
|
|
2019-07-06 15:13:06 +02:00
|
|
|
});
|