smartfm/test/test.ts

27 lines
850 B
TypeScript
Raw Normal View History

2017-05-27 21:02:51 +00:00
import { tap, expect } from 'tapbundle'
2016-11-13 22:11:49 +00:00
import * as smartfm from '../dist/index'
2017-05-27 21:02:51 +00:00
let testSmartfm = new smartfm.Smartfm({ fmType: 'yaml' })
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).to.equal(testString)
})
tap.test('.stringify', 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)
2016-11-13 22:11:49 +00:00
})
2017-05-27 21:02:51 +00:00
tap.start()