0f9ddf1e5d
* 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
44 lines
1.1 KiB
JavaScript
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)
|
|
})
|
|
})
|