wikijs-fork/server/test/helpers/page.test.js
rbtprograms 0f9ddf1e5d fix: Switch converted to Object Literal (#940)
* updating a switch into object literal and fixed a couple linter errors

* added a comment about weird formatting

* style: use lodash get

* fix: pass eslint + puglint + jest
2019-08-04 16:31:13 -04:00

44 lines
1.1 KiB
JavaScript

const { injectPageMetadata } = require('../../helpers/page')
describe('injectPageMetadata tests', () => {
let page = {
title: 'PAGE TITLE',
description: 'A PAGE',
isPublished: true,
updatedAt: new Date(),
content: 'TEST CONTENT'
}
test('injectPageMetadata: default', () => {
const expected = 'TEST CONTENT'
const result = injectPageMetadata(page)
expect(result).toEqual(expected)
})
test('injectPageMetadata: markdown', () => {
page.contentType = 'markdown'
const expected = `---
title: ${page.title}
description: ${page.description}
published: ${page.isPublished.toString()}
date: ${page.updatedAt}
tags: \n---
TEST CONTENT`
const result = injectPageMetadata(page)
expect(result).toEqual(expected)
})
test('injectPageMetadata: hmtl', () => {
page.contentType = 'html'
const expected = `<!--
title: ${page.title}
description: ${page.description}
published: ${page.isPublished.toString()}
date: ${page.updatedAt}
tags: \n-->
TEST CONTENT`
const result = injectPageMetadata(page)
expect(result).toEqual(expected)
})
})