websocket.spec.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* global expect, it, describe, WS */
  2. /*
  3. jasmine tests for Snowflake websocket
  4. */
  5. describe('BuildUrl', function() {
  6. it('should parse just protocol and host', function() {
  7. expect(WS.buildUrl('http', 'example.com')).toBe('http://example.com');
  8. });
  9. it('should handle different ports', function() {
  10. expect(WS.buildUrl('http', 'example.com', 80)).toBe('http://example.com');
  11. expect(WS.buildUrl('http', 'example.com', 81)).toBe('http://example.com:81');
  12. expect(WS.buildUrl('http', 'example.com', 443)).toBe('http://example.com:443');
  13. expect(WS.buildUrl('http', 'example.com', 444)).toBe('http://example.com:444');
  14. });
  15. it('should handle paths', function() {
  16. expect(WS.buildUrl('http', 'example.com', 80, '/')).toBe('http://example.com/');
  17. expect(WS.buildUrl('http', 'example.com', 80, '/test?k=%#v')).toBe('http://example.com/test%3Fk%3D%25%23v');
  18. expect(WS.buildUrl('http', 'example.com', 80, '/test')).toBe('http://example.com/test');
  19. });
  20. it('should handle params', function() {
  21. expect(WS.buildUrl('http', 'example.com', 80, '/test', [['k', '%#v']])).toBe('http://example.com/test?k=%25%23v');
  22. expect(WS.buildUrl('http', 'example.com', 80, '/test', [['a', 'b'], ['c', 'd']])).toBe('http://example.com/test?a=b&c=d');
  23. });
  24. it('should handle ips', function() {
  25. expect(WS.buildUrl('http', '1.2.3.4')).toBe('http://1.2.3.4');
  26. expect(WS.buildUrl('http', '1:2::3:4')).toBe('http://[1:2::3:4]');
  27. });
  28. it('should handle bogus', function() {
  29. expect(WS.buildUrl('http', 'bog][us')).toBe('http://bog%5D%5Bus');
  30. expect(WS.buildUrl('http', 'bog:u]s')).toBe('http://bog%3Au%5Ds');
  31. });
  32. });