Created
May 16, 2023 01:57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const append = (demo = '', file = '') => { | |
const params = new URLSearchParams({ | |
...(file ? { file } : {}), | |
ctl: 1, | |
embed: 1, | |
}) | |
return `/${demo}?${params}` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { append } from './main.js' | |
import test from 'node:test' | |
import assert from 'node:assert/strict' | |
test('handles having both demo and file', () => { | |
const out = append('demo', 'file') | |
assert.strictEqual(out, '/demo?file=file&ctl=1&embed=1') | |
}) | |
test('handles only demo', () => { | |
const out = append('demo', undefined) | |
assert.strictEqual(out, '/demo?ctl=1&embed=1') | |
}) | |
test('handles only file', () => { | |
const out = append(undefined, 'file') | |
assert.strictEqual(out, '/?file=file&ctl=1&embed=1') | |
}) | |
test('handles missing demo and file', () => { | |
const out = append(undefined, undefined) | |
assert.strictEqual(out, '/?ctl=1&embed=1') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment