You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
const { assert } = require('chai')
|
|
|
|
const fs = require('fs')
|
|
|
|
|
|
|
|
describe('Parser Markdown', function () {
|
|
|
|
|
|
|
|
// default file
|
|
|
|
const markdownData = fs.readFileSync('./ressources/index.md', 'utf8')
|
|
|
|
|
|
|
|
// get function parseMarkdownFile
|
|
|
|
const parseMarkdownFile = require('./../src/parsers/markdown.js')
|
|
|
|
|
|
|
|
// start parsing
|
|
|
|
const result = parseMarkdownFile(markdownData)
|
|
|
|
|
|
|
|
// check results
|
|
|
|
it('fields exists', function() {
|
|
|
|
assert.notEqual(result.fields, undefined)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('fields is object', function() {
|
|
|
|
assert.isObject(result.fields)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('fields are valid', function() {
|
|
|
|
assert.deepEqual(result.fields, {
|
|
|
|
media: {
|
|
|
|
src: {
|
|
|
|
sizes: [{
|
|
|
|
width: 300
|
|
|
|
},
|
|
|
|
{
|
|
|
|
height: 100,
|
|
|
|
width: 500
|
|
|
|
}
|
|
|
|
],
|
|
|
|
src: '_images/dog.jpg'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
title: 'health goth DIY tattooed',
|
|
|
|
view: 'page.njk',
|
|
|
|
meta: {
|
|
|
|
description: 'DSA yes plz hot chicken green juice',
|
|
|
|
robots: 'noindex'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('content exists', function() {
|
|
|
|
assert.notEqual(result.content, '')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('content has html', function() {
|
|
|
|
assert.match(result.content, /<h2 id="normcore-cold-pressed-ramps-dsa">Normcore cold-pressed ramps DSA<\/h2>/)
|
|
|
|
})
|
|
|
|
})
|