mirror of https://github.com/requarks/wiki
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.
44 lines
1.1 KiB
44 lines
1.1 KiB
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)
|
|
})
|
|
})
|