fix(build): modernize project configuration and test setup for current toolchain compatibility
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
|
||||
import * as smartfm from '../ts/index.js';
|
||||
|
||||
let testSmartfm = new smartfm.Smartfm({ fmType: 'yaml' });
|
||||
tap.test('.parse()', async () => {
|
||||
let testString = `---
|
||||
testKey: testValue
|
||||
testKey2: testValue2
|
||||
---
|
||||
# some markdown
|
||||
`;
|
||||
let parsedString = testSmartfm.parse(testString);
|
||||
expect(parsedString.data).toHaveProperty('testKey', 'testValue');
|
||||
expect(parsedString.data).toHaveProperty('testKey2', 'testValue2');
|
||||
expect(parsedString.orig.toString()).toEqual(testString);
|
||||
});
|
||||
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).toEqual(testStringCombined);
|
||||
});
|
||||
|
||||
tap.test('should parse a normal frontmatter file', async () => {
|
||||
const normalFile = `---
|
||||
heythere: awesome
|
||||
---
|
||||
really
|
||||
`;
|
||||
let result = testSmartfm.parse(normalFile);
|
||||
expect(result.data.heythere).toEqual('awesome');
|
||||
});
|
||||
|
||||
tap.test('should parse a commented out frontmatter file', async () => {
|
||||
const commentedFile = `# ---
|
||||
# heythere: awesome
|
||||
# ---
|
||||
really
|
||||
`;
|
||||
let result = testSmartfm.parseFromComments('# ', commentedFile);
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user