smartfm/test/test.ts

30 lines
968 B
TypeScript
Raw Normal View History

import { tap, expect } from '@pushrocks/tapbundle';
2016-11-13 22:11:49 +00:00
import * as smartfm from '../ts/index';
2016-11-13 22:11:49 +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
`;
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);
});
2019-09-04 12:13:42 +00:00
tap.test('should stringify data', async () => {
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
2019-09-04 12:13:42 +00:00
tap.test('should parse a normal frontmatter file', async () => {
});
tap.start();