Skip to content

Commit cf8f20c

Browse files
committed
test(unescape): add test coverage
1 parent 2b760b1 commit cf8f20c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/unescape.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { assert } from 'chai';
2+
3+
import { unescape } from '../src/index.js';
4+
5+
describe('unescape', function () {
6+
it('should replace "~1" with "/"', function () {
7+
assert.strictEqual(unescape('foo~1bar'), 'foo/bar');
8+
});
9+
10+
it('should replace "~0" with "~"', function () {
11+
assert.strictEqual(unescape('foo~0bar'), 'foo~bar');
12+
});
13+
14+
it('should replace both "~1" and "~0" correctly', function () {
15+
assert.strictEqual(unescape('foo~1bar~0baz'), 'foo/bar~baz');
16+
});
17+
18+
it('should handle multiple occurrences of "~1" and "~0"', function () {
19+
assert.strictEqual(unescape('~1foo~0bar~1baz~0qux'), '/foo~bar/baz~qux');
20+
});
21+
22+
it('should return the same string if there are no "~1" or "~0" sequences', function () {
23+
assert.strictEqual(unescape('foobar'), 'foobar');
24+
});
25+
26+
it('should handle an empty string correctly', function () {
27+
assert.strictEqual(unescape(''), '');
28+
});
29+
30+
it('should not modify unrelated characters', function () {
31+
assert.strictEqual(unescape('foo-bar_baz~9'), 'foo-bar_baz~9');
32+
});
33+
});

0 commit comments

Comments
 (0)