Skip to content

Commit

Permalink
util/http: add tests for url template strings (#1282)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn authored Nov 10, 2024
1 parent 9ba21ef commit 57beb4b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/unit/util/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,31 @@ describe('util/http', () => {
});
});

describe('url()', () => {
const { url } = http;

const a = 'a space';
const b = 'funnyȩ¸iê';
const c = '100%';
const d = 999;
const e = { toString: () => 'e!' };

[
[ url``, '' ],
[ url`/`, '/' ],
[ url`/${a}`, '/a%20space' ],
[ url`/${b}`, '/funny%C8%A9%C2%B8i%C3%AA' ],
[ url`/${c}`, '/100%25' ],
[ url`/${d}`, '/999' ],
[ url`/${e}`, '/e!' ],
[ url`/${a}/${b}?c=${c}&d=${d}&e=${e}x`, '/a%20space/funny%C8%A9%C2%B8i%C3%AA?c=100%25&d=999&e=e!x' ],
].forEach(([ actual, expected ]) => {
it(`should correctly encode ${expected}`, () => {
actual.should.equal(expected);
});
});
});

describe('urlPathname', () => {
const { urlPathname } = http;
it('should return the pathname part of a url', () => {
Expand Down

0 comments on commit 57beb4b

Please sign in to comment.