Merging this separately so the commit with the tooling change is readable. This is a follow-on to #1167 which turned prettier on.
30 lines
780 B
JavaScript
30 lines
780 B
JavaScript
import { test, given, forCases } from 'sazerac'
|
|
import resolveUrl from './resolve-url'
|
|
|
|
describe('URL resolver', function() {
|
|
test(resolveUrl, () => {
|
|
forCases([
|
|
given('/foo/bar'),
|
|
given('/foo/bar', '/'),
|
|
given('/foo/bar', '/baz'),
|
|
given('/foo/bar', '/baz/'),
|
|
given('/foo/bar', ''),
|
|
given('/foo/bar', undefined),
|
|
]).expect('/foo/bar')
|
|
|
|
given('foo/bar', '/baz/').expect('/baz/foo/bar')
|
|
|
|
forCases([
|
|
given('http://foo/bar'),
|
|
given('bar', 'http://foo/'),
|
|
given('/bar', 'http://foo/'),
|
|
]).expect('http://foo/bar')
|
|
|
|
given('/foo/bar', '/baz', { baz: 'bazinga' }).expect('/foo/bar?baz=bazinga')
|
|
|
|
given('/foo/bar?thing=1', undefined, { other: '2' }).expect(
|
|
'/foo/bar?thing=1&other=2'
|
|
)
|
|
})
|
|
})
|