deno.land / x / urlcat@v3.1.0 / test / configure.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { configure } from '../src';
describe('configure', () => { it('Should create decorator for urlcat with a configuration', () => { const expected = 'http://example.com/path/a%20b?q=b+c'; const urlcat = configure({ objectFormat: { format: 'RFC1738' } })
const actual = urlcat('http://example.com/path/:p', { p: 'a b', q: 'b c' }); expect(actual).toBe(expected); });
it('Should create decorator for urlcat and override with custom configuration configuration', () => { const expected = 'http://example.com/path/a%20b?q=b%20c'; const urlcat = configure({ objectFormat: { format: 'RFC1738' } })
const actual = urlcat('http://example.com/path/:p', { p: 'a b', q: 'b c' }, undefined, { objectFormat: { format: 'RFC3986' } }); expect(actual).toBe(expected); });
it('Should create decorator for urlcat with all configuration options', () => { const expected = 'http://example.com/path/a%20b?q=b+c&c=foo&c=bar'; const urlcat = configure({ objectFormat: { format: 'RFC1738' }, arrayFormat: 'repeat' })
const actual = urlcat('http://example.com/path/:p', { p: 'a b', q: 'b c', c: ['foo', 'bar'] }); expect(actual).toBe(expected); });
it('Should create decorator for urlcat with all configuration options and override with custom configuration', () => { const expected = 'http://example.com/path/a%20b?q=b%20c&c=foo%2Cbar'; const urlcat = configure({ objectFormat: { format: 'RFC1738' }, arrayFormat: 'repeat' })
const actual = urlcat('http://example.com/path/:p', { p: 'a b', q: 'b c', c: ['foo', 'bar'] }, undefined, { arrayFormat: 'comma', objectFormat: { format: 'RFC3986' } }); expect(actual).toBe(expected); });
it('Creates a decorator that supports the 3-parameter overload', () => { const expected = 'http://example.com/path/1'; const urlcat = configure({ objectFormat: { format: 'RFC1738' } })
const actual = urlcat('http://example.com/', '/path/:p', { p: 1 }); expect(actual).toBe(expected); });});
urlcat

Version Info

Tagged at
a year ago