-
-
Notifications
You must be signed in to change notification settings - Fork 776
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for leading newlines when determining if block indentation indi…
…cator is needed (#404) * Check for leading newlines when determining if block indentation indicator is needed Fixes #403 * Perf: Swap order of checks for block indentation edge case
- Loading branch information
Showing
2 changed files
with
30 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
|
||
var assert = require('assert'); | ||
var yaml = require('../../'); | ||
|
||
|
||
test('should properly dump leading newlines and spaces', function () { | ||
var dump, src; | ||
|
||
src = { str: '\n a\nb' }; | ||
dump = yaml.dump(src); | ||
assert.deepEqual(yaml.safeLoad(dump), src); | ||
|
||
src = { str: '\n\n a\nb' }; | ||
dump = yaml.dump(src); | ||
assert.deepEqual(yaml.safeLoad(dump), src); | ||
|
||
src = { str: '\n a\nb' }; | ||
dump = yaml.dump(src, { indent: 10 }); | ||
assert.deepEqual(yaml.safeLoad(dump), src); | ||
}); |