added more tests for url

pull/11774/head
godzylinux 2 years ago
parent 852205144b
commit 37cdebe434

@ -22,6 +22,7 @@ test('URLSearchParams.set', () => {
});
flushSync(() => {
// nothing should happen here
params.set('a', 'c');
});
@ -45,6 +46,7 @@ test('URLSearchParams.append', () => {
});
flushSync(() => {
// nothing should happen here
params.set('a', 'b');
});
@ -72,6 +74,7 @@ test('URLSearchParams.delete', () => {
});
flushSync(() => {
// nothing should happen here
params.delete('a');
});
@ -123,6 +126,7 @@ test('URLSearchParams.getAll', () => {
log.push(params.get('a'));
});
render_effect(() => {
// this should only logged once because other changes shouldn't affect this
log.push(params.get('c'));
});
render_effect(() => {

@ -73,3 +73,40 @@ test('url.searchParams', () => {
cleanup();
});
test('url.href', () => {
const url = new ReactiveURL('https://svelte.dev?foo=bar&t=123');
const log: any = [];
const cleanup = effect_root(() => {
render_effect(() => {
log.push(url.href);
});
});
flushSync(() => {
url.search = '?q=kit&foo=baz';
});
flushSync(() => {
url.searchParams.append('foo', 'qux');
});
flushSync(() => {
url.searchParams.delete('foo');
});
flushSync(() => {
url.searchParams.set('love', 'svelte5');
});
assert.deepEqual(log, [
'https://svelte.dev/?foo=bar&t=123',
'https://svelte.dev/?q=kit&foo=baz',
'https://svelte.dev/?q=kit&foo=baz&foo=qux',
'https://svelte.dev/?q=kit',
'https://svelte.dev/?q=kit&love=svelte5'
]);
cleanup();
});

Loading…
Cancel
Save