smartfm/test/test.ts

26 lines
937 B
TypeScript
Raw Permalink Normal View History

2016-11-13 22:11:49 +00:00
import 'typings-test'
import * as should from 'should'
import * as smartfm from '../dist/index'
2016-11-14 12:04:25 +00:00
describe('smartfm', function () {
let testSmartfm = new smartfm.Smartfm({ fmType: 'yaml' })
it('.parse()', function () {
2016-11-13 22:11:49 +00:00
let testString = `---
testKey: testValue
testKey2: testValue2
---
# some markdown`
let parsedString = testSmartfm.parse(testString)
2016-11-14 12:04:25 +00:00
should(parsedString.data).have.property('testKey', 'testValue')
should(parsedString.data).have.property('testKey2', 'testValue2')
2016-11-13 22:11:49 +00:00
should(parsedString.orig).equal(testString)
})
2016-11-14 12:04:25 +00:00
it('.stringify', function () {
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'
should(resultString).equal(testStringCombined)
2016-11-13 22:11:49 +00:00
})
})