2018-08-27 00:01:18 +00:00
|
|
|
import { tap, expect } from '@pushrocks/tapbundle';
|
2016-11-13 22:11:49 +00:00
|
|
|
|
2018-08-27 00:01:18 +00:00
|
|
|
import * as smartfm from '../ts/index';
|
2016-11-13 22:11:49 +00:00
|
|
|
|
2018-08-27 00:01:18 +00:00
|
|
|
let testSmartfm = new smartfm.Smartfm({ fmType: 'yaml' });
|
2017-05-27 21:02:51 +00:00
|
|
|
tap.test('.parse()', async () => {
|
|
|
|
let testString = `---
|
2016-11-13 22:11:49 +00:00
|
|
|
testKey: testValue
|
|
|
|
testKey2: testValue2
|
|
|
|
---
|
2017-05-27 21:02:51 +00:00
|
|
|
# some markdown
|
2018-08-27 00:01:18 +00:00
|
|
|
`;
|
|
|
|
let parsedString = testSmartfm.parse(testString);
|
|
|
|
expect(parsedString.data).to.have.property('testKey', 'testValue');
|
|
|
|
expect(parsedString.data).to.have.property('testKey2', 'testValue2');
|
|
|
|
expect(parsedString.orig.toString()).to.equal(testString);
|
|
|
|
});
|
2017-05-27 21:02:51 +00:00
|
|
|
tap.test('.stringify', async () => {
|
2018-08-27 00:01:18 +00:00
|
|
|
let testStringPure = `# some markdown heading\nsome first row`;
|
|
|
|
let testStringCombined = testSmartfm.stringify(testStringPure, { testData: 'hi' });
|
|
|
|
let resultString = '---\ntestData: hi\n---\n# some markdown heading\nsome first row\n';
|
|
|
|
expect(resultString).to.equal(testStringCombined);
|
|
|
|
});
|
2017-05-27 21:02:51 +00:00
|
|
|
|
2018-08-27 00:01:18 +00:00
|
|
|
tap.start();
|