Skip to content

Commit

Permalink
Improve tests (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richienb committed Jul 12, 2022
1 parent 1794b86 commit 7cfa81f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Expand Up @@ -282,6 +282,7 @@ export function hasProperty(object, path) {
return true;
}

// TODO: Backslashes with no effect should not be escaped
export function escapePath(path) {
if (typeof path !== 'string') {
throw new TypeError('Expected a string');
Expand Down
4 changes: 4 additions & 0 deletions test.js
Expand Up @@ -397,6 +397,10 @@ test('escapePath', t => {
t.is(escapePath('foo[0].bar'), 'foo\\[0]\\.bar');
t.is(escapePath('foo.bar[0].baz'), 'foo\\.bar\\[0]\\.baz');
t.is(escapePath('[0].foo'), '\\[0]\\.foo');
// TODO: The following three tests assume that backslashes with no effect are escaped. Update when this changes.
t.is(escapePath('\\foo'), '\\\\foo');
t.is(escapePath('foo\\'), 'foo\\\\');
t.is(escapePath('foo\\\\'), 'foo\\\\\\\\');
t.is(escapePath(''), '');

t.throws(() => {
Expand Down

0 comments on commit 7cfa81f

Please sign in to comment.