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.

43 lines
1.1 KiB

  1. const { injectPageMetadata } = require('../../helpers/page')
  2. describe('injectPageMetadata tests', () => {
  3. let page = {
  4. title: 'PAGE TITLE',
  5. description: 'A PAGE',
  6. isPublished: true,
  7. updatedAt: new Date(),
  8. content: 'TEST CONTENT'
  9. }
  10. test('injectPageMetadata: default', () => {
  11. const expected = 'TEST CONTENT'
  12. const result = injectPageMetadata(page)
  13. expect(result).toEqual(expected)
  14. })
  15. test('injectPageMetadata: markdown', () => {
  16. page.contentType = 'markdown'
  17. const expected = `---
  18. title: ${page.title}
  19. description: ${page.description}
  20. published: ${page.isPublished.toString()}
  21. date: ${page.updatedAt}
  22. tags: \n---
  23. TEST CONTENT`
  24. const result = injectPageMetadata(page)
  25. expect(result).toEqual(expected)
  26. })
  27. test('injectPageMetadata: hmtl', () => {
  28. page.contentType = 'html'
  29. const expected = `<!--
  30. title: ${page.title}
  31. description: ${page.description}
  32. published: ${page.isPublished.toString()}
  33. date: ${page.updatedAt}
  34. tags: \n-->
  35. TEST CONTENT`
  36. const result = injectPageMetadata(page)
  37. expect(result).toEqual(expected)
  38. })
  39. })