-
-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(loader): Add support for
safe/loadAll(input, options)
- Loading branch information
Showing
2 changed files
with
67 additions
and
7 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,54 @@ | ||
'use strict'; | ||
|
||
var assert = require('assert'); | ||
var yaml = require('../..'); | ||
|
||
suite('loader parameters', function () { | ||
var testStr = 'test: 1 \ntest: 2'; | ||
var expected = [ { test: 2 } ]; | ||
var result; | ||
|
||
test('loadAll(input, options)', function () { | ||
result = yaml.loadAll(testStr, { json: true }); | ||
assert.deepEqual(result, expected); | ||
|
||
result = []; | ||
yaml.loadAll(testStr, function (doc) { | ||
result.push(doc); | ||
}, { json: true }); | ||
assert.deepEqual(result, expected); | ||
}); | ||
|
||
test('loadAll(input, null, options)', function () { | ||
result = yaml.loadAll(testStr, null, { json: true }); | ||
assert.deepEqual(result, expected); | ||
|
||
result = []; | ||
yaml.loadAll(testStr, function (doc) { | ||
result.push(doc); | ||
}, { json: true }); | ||
assert.deepEqual(result, expected); | ||
}); | ||
|
||
test('safeLoadAll(input, options)', function () { | ||
result = yaml.safeLoadAll(testStr, { json: true }); | ||
assert.deepEqual(result, expected); | ||
|
||
result = []; | ||
yaml.safeLoadAll(testStr, function (doc) { | ||
result.push(doc); | ||
}, { json: true }); | ||
assert.deepEqual(result, expected); | ||
}); | ||
|
||
test('safeLoadAll(input, null, options)', function () { | ||
result = yaml.safeLoadAll(testStr, null, { json: true }); | ||
assert.deepEqual(result, expected); | ||
|
||
result = []; | ||
yaml.safeLoadAll(testStr, function (doc) { | ||
result.push(doc); | ||
}, { json: true }); | ||
assert.deepEqual(result, expected); | ||
}); | ||
}); |