Skip to content

Commit

Permalink
Add additional unit tests around URL-encoding across environments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaswrks committed Mar 16, 2024
1 parent aebeeb7 commit f74abe5
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/tests/url/any.cfw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* Test suite.
*/

import './index.any.ts';
5 changes: 5 additions & 0 deletions src/tests/url/any.node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* Test suite.
*/

import './index.any.ts';
8 changes: 8 additions & 0 deletions src/tests/url/any.web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Test suite.
*/

Object.defineProperty(window, 'location', {
value: new URL('https://localhost:3000/'),
});
import './index.any.ts';
3 changes: 3 additions & 0 deletions src/tests/url/index.any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ describe('$url', async () => {
expect($url.addQueryVars({ abc: 'a.b.c' }, '../path/xyz.ext?abc=abc&y=0&x=0&z=0', new URL('https://abc.tld/'), { replaceExisting: true })).toBe(
'/path/xyz.ext?abc=a.b.c&x=0&y=0&z=0',
);
expect($url.addQueryVars({ abc: 'a:b:c' }, new URL('https://abc.tld/path/xyz.ext?abc=abc&y=0:0&x=0&z=0').toString())).toBe(
'https://abc.tld/path/xyz.ext?abc=a%3Ab%3Ac&x=0&y=0%3A0&z=0',
);
});
test('.removeQueryVar()', async () => {
expect($url.removeQueryVar('abc', 'https://abc.tld/path/xyz.ext?abc=')).toBe('https://abc.tld/path/xyz.ext');
Expand Down
51 changes: 51 additions & 0 deletions src/tests/url/index.cfw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Test suite.
*/

import { $url } from '#index.ts';
import { describe, expect, test } from 'vitest';

describe('$url', async () => {
test('.current()', async () => {
expect(() => $url.current()).toThrow();
});
test('.currentReferrer()', async () => {
expect(() => $url.currentReferrer()).toThrow();
});
test('.currentScheme()', async () => {
expect(() => $url.currentScheme()).toThrow();
});
test('.currentHost()', async () => {
expect(() => $url.currentHost()).toThrow();
});
test('.currentRootHost()', async () => {
expect(() => $url.currentRootHost()).toThrow();
});
test('.currentPort()', async () => {
expect(() => $url.currentPort()).toThrow();
});
test('.currentPath()', async () => {
expect(() => $url.currentPath()).toThrow();
});
test('.currentSubpath()', async () => {
expect(() => $url.currentSubpath()).toThrow();
});
test('.currentQuery()', async () => {
expect(() => $url.currentQuery()).toThrow();
});
test('.currentHash()', async () => {
expect(() => $url.currentHash()).toThrow();
});
test('.currentPathQuery()', async () => {
expect(() => $url.currentPathQuery()).toThrow();
});
test('.currentPathQueryHash()', async () => {
expect(() => $url.currentPathQueryHash()).toThrow();
});
test('.currentBase()', async () => {
expect(() => $url.currentBase()).toThrow();
});
test('.currentBasePath()', async () => {
expect(() => $url.currentBasePath()).toThrow();
});
});

0 comments on commit f74abe5

Please sign in to comment.