summary refs log tree commit diff stats
path: root/test/modules/posts.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/modules/posts.test.js')
-rw-r--r--test/modules/posts.test.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/modules/posts.test.js b/test/modules/posts.test.js
new file mode 100644
index 0000000..28a25f2
--- /dev/null
+++ b/test/modules/posts.test.js
@@ -0,0 +1,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)
+})