summary refs log tree commit diff stats
path: root/test/modules/posts.test.js
blob: 28a25f26fa3bbf5c5e1e11d594f450c017c97bc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const test = require('ava')
const path = require('path')

const posts = require('../../src/modules/posts.js')

test('get', t => {
  const expected = new Map(
    Object.entries({
      title: 'This is a test',
      description: 'Test file',
      tags: ['a', 'b']
    })
  )
  const meta = posts.get(path.resolve(__dirname, '../data/testfile.md'))
  t.deepEqual(meta.data, expected)
})

test('getFolder', t => {
  const expected = new Map(
    Object.entries({
      title: 'This is a test',
      description: 'Test file',
      tags: ['a', 'b']
    })
  )
  const actual = posts.getFolder(path.resolve(__dirname, '../data/'))
  t.true(Array.isArray(actual), 'must return an array')
  t.true(actual.length > 0, 'must return a non-empty array')
  t.is(actual[0].path, path.resolve(__dirname, '../data/testfile.md'))
  t.deepEqual(actual[0].data, expected)
})