github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/ui-v2/tests/unit/utils/createURL-test.js (about) 1 import { module, skip } from 'ember-qunit'; 2 import test from 'ember-sinon-qunit/test-support/test'; 3 import createURL from 'consul-ui/utils/createURL'; 4 module('Unit | Utils | createURL', {}); 5 6 skip("it isn't isolated enough, mock encodeURIComponent"); 7 test('it passes the values to encode', function(assert) { 8 [ 9 { 10 args: [ 11 ['/v1/url'], 12 ['raw', 'values', 'to', 'encode'], 13 { 14 query: 'to encode', 15 ['key with']: ' spaces ', 16 }, 17 ], 18 expected: '/v1/url/raw/values/to/encode?query=to%20encode&key%20with=%20spaces%20', 19 }, 20 ].forEach(function(item) { 21 const actual = createURL(...item.args); 22 assert.equal(actual, item.expected); 23 }); 24 }); 25 test('it adds a query string key without an `=` if the query value is `null`', function(assert) { 26 [ 27 { 28 args: [ 29 ['/v1/url'], 30 ['raw', 'values', 'to', 'encode'], 31 { 32 query: null, 33 }, 34 ], 35 expected: '/v1/url/raw/values/to/encode?query', 36 }, 37 ].forEach(function(item) { 38 const actual = createURL(...item.args); 39 assert.equal(actual, item.expected); 40 }); 41 }); 42 test("it returns a string with no query string if you don't pass a query string object", function(assert) { 43 [ 44 { 45 args: [['/v1/url'], ['raw', 'values', 'to', 'encode']], 46 expected: '/v1/url/raw/values/to/encode', 47 }, 48 ].forEach(function(item) { 49 const actual = createURL(...item.args); 50 assert.equal(actual, item.expected); 51 }); 52 });