-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start lines that need folding on a new line (#13)
- Loading branch information
Showing
3 changed files
with
148 additions
and
93 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,50 @@ | ||
const { stringify } = require('../lib/index') | ||
|
||
describe('Folding for long lines', () => { | ||
test('long value starts on new line', () => { | ||
const lines = [ | ||
['k0', '0 val0'], | ||
['k1', '1 value1'], | ||
['key', 'v0'], | ||
['key1', 'value1'], | ||
['key2', 'value2 continues'] | ||
] | ||
expect(stringify(lines, { indent: ' ', lineWidth: 8 })).toBe( | ||
`\ | ||
k0 = \\ | ||
0 val0 | ||
k1 = \\ | ||
1 \\ | ||
value1 | ||
key = v0 | ||
key1 = \\ | ||
value1 | ||
key2 = \\ | ||
value2\\ | ||
\\ \\ | ||
contin\\ | ||
ues` | ||
) | ||
}) | ||
|
||
test('values after long keys do not start on new line', () => { | ||
const lines = [ | ||
['longish key', 'v0'], | ||
['longkeyxx', '42'], | ||
['somelongkey', 'withlongvalue'] | ||
] | ||
expect(stringify(lines, { indent: ' ', lineWidth: 8 })).toBe( | ||
`\ | ||
longish\\ \\ | ||
key = \\ | ||
v0 | ||
longkeyx\\ | ||
x = 42 | ||
somelong\\ | ||
key = \\ | ||
withlo\\ | ||
ngvalu\\ | ||
e` | ||
) | ||
}) | ||
}) |