File: test.js

package info (click to toggle)
node-source-map-resolve 0.6.0%2B~cs2.7.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 356 kB
  • sloc: javascript: 1,873; makefile: 5
file content (54 lines) | stat: -rw-r--r-- 1,198 bytes parent folder | download | duplicates (2)
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
45
46
47
48
49
50
51
52
53
54
const test = require('tape');
const m = require('./');

const tests = {
	'test': 'test',
	'a+b': 'a b',
	'a+b+c+d': 'a b c d',
	'=a': '=a',
	'%': '%',
	'%25': '%',
	'%%25%%': '%%%%',
	'st%C3%A5le': 'ståle',
	'st%C3%A5le%': 'ståle%',
	'%st%C3%A5le%': '%ståle%',
	'%%7Bst%C3%A5le%7D%': '%{ståle}%',
	'%ab%C3%A5le%': '%abåle%',
	'%C3%A5%able%': 'å%able%',
	'%7B%ab%7C%de%7D': '{%ab|%de}',
	'%7B%ab%%7C%de%%7D': '{%ab%|%de%}',
	'%7 B%ab%%7C%de%%7 D': '%7 B%ab%|%de%%7 D',
	'%ab': '%ab',
	'%ab%ab%ab': '%ab%ab%ab',
	'%61+%4d%4D': 'a MM',
	'\uFEFFtest': '\uFEFFtest',
	'\uFEFF': '\uFEFF',
	'%EF%BB%BFtest': '\uFEFFtest',
	'%EF%BB%BF': '\uFEFF',
	'%FE%FF': '\uFFFD\uFFFD',
	'%FF%FE': '\uFFFD\uFFFD',
	'†': '†',
	'%C2': '\uFFFD',
	'%C2x': '\uFFFDx',
	'%C2%B5': 'µ',
	'%C2%B5%': 'µ%',
	'%%C2%B5%': '%µ%'
};

function macro(t, input, expected) {
	t.is(m(input), expected);
	t.end();
}

macro.title = (providedTitle, input, expected) => `${input} → ${expected}`;

test('type error', t => {
	t.throws(() => m(5), 'Expected `encodedURI` to be of type `string`, got `number`');
	t.end();
});

for (const input of Object.keys(tests)) {
	test(input, t => {
	    macro(t, input, tests[input])
	});
}