-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a494c68
commit 851191e
Showing
3 changed files
with
64 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const utility = require('../src/utility.js'); | ||
|
||
test('normalises path', () => { | ||
expect(utility.normalisePath('./hello.txt')).toEqual('hello.txt'); | ||
expect(utility.normalisePath('.')).toEqual(''); | ||
expect(utility.normalisePath('./')).toEqual(''); | ||
expect(utility.normalisePath('/abc//def')).toEqual('/abc/def'); | ||
}); | ||
|
||
test('strips top path', () => { | ||
expect(utility.stripTopPath('hello/hello.txt', 'hello/')).toEqual('hello.txt'); | ||
expect(utility.stripTopPath('hello/hello.txt', 'hello')).toEqual('/hello.txt'); | ||
expect(utility.stripTopPath('hello/hello.txt', '/hello')).toEqual('hello/hello.txt'); | ||
expect(utility.stripTopPath('/hello/hello.txt', 'hello')).toEqual('/hello/hello.txt'); | ||
expect(utility.stripTopPath('hello/hello.txt', 'goodbye')).toEqual('hello/hello.txt'); | ||
}); | ||
|
||
|
||
test('stringifies json', () => { | ||
expect(utility.stringifyJson({ hello: 'there' })).toEqual('{\n\t"hello": "there"\n}') | ||
}); | ||
|
||
test('stringifies circular json', () => { | ||
const circular = { hello: 'there' }; | ||
circular.oops = circular; | ||
|
||
const expected = '{\n\t"hello": "there",\n\t"oops": "[Circular]"\n}'; | ||
expect(utility.stringifyJson(circular)).toEqual(expected); | ||
}); |