2016-11-13 22:11:49 +00:00
|
|
|
"use strict";
|
|
|
|
require("typings-test");
|
|
|
|
const should = require("should");
|
|
|
|
const smartfm = require("../dist/index");
|
|
|
|
describe('smartfm', function () {
|
2016-11-14 12:04:25 +00:00
|
|
|
let testSmartfm = new smartfm.Smartfm({ fmType: 'yaml' });
|
2016-11-13 22:11:49 +00:00
|
|
|
it('.parse()', function () {
|
|
|
|
let testString = `---
|
|
|
|
testKey: testValue
|
|
|
|
testKey2: testValue2
|
|
|
|
---
|
|
|
|
# some markdown`;
|
|
|
|
let parsedString = testSmartfm.parse(testString);
|
|
|
|
should(parsedString.data).have.property('testKey', 'testValue');
|
|
|
|
should(parsedString.data).have.property('testKey2', 'testValue2');
|
|
|
|
should(parsedString.orig).equal(testString);
|
|
|
|
});
|
|
|
|
it('.stringify', function () {
|
2016-11-14 12:04:25 +00:00
|
|
|
let testStringPure = `# some markdown heading\nsome first row`;
|
2016-11-13 22:11:49 +00:00
|
|
|
let testStringCombined = testSmartfm.stringify(testStringPure, { testData: 'hi' });
|
2016-11-14 12:04:25 +00:00
|
|
|
let resultString = '---\ntestData: hi\n---\n# some markdown heading\nsome first row\n';
|
|
|
|
should(resultString).equal(testStringCombined);
|
2016-11-13 22:11:49 +00:00
|
|
|
});
|
|
|
|
});
|
2016-11-14 12:04:25 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFFaEMseUNBQXdDO0FBRXhDLFFBQVEsQ0FBQyxTQUFTLEVBQUU7SUFDaEIsSUFBSSxXQUFXLEdBQUcsSUFBSSxPQUFPLENBQUMsT0FBTyxDQUFDLEVBQUUsTUFBTSxFQUFFLE1BQU0sRUFBRSxDQUFDLENBQUE7SUFDekQ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