about summary refs log tree commit diff stats
path: root/test/modules
diff options
context:
space:
mode:
authorAlan Pearce2017-06-18 12:24:24 +0200
committerAlan Pearce2017-06-18 12:24:24 +0200
commitda9ff90d3e1b1348c43cd378c0806e159a700810 (patch)
treeab81bc58d982c6ffe77e160ae9b107acdc72eee6 /test/modules
parent3bda5fcfb7a23619ba66bef029d89bbd18d2c915 (diff)
downloadhomestead-da9ff90d3e1b1348c43cd378c0806e159a700810.tar.lz
homestead-da9ff90d3e1b1348c43cd378c0806e159a700810.tar.zst
homestead-da9ff90d3e1b1348c43cd378c0806e159a700810.zip
feat: Parse front matter as metadata
Diffstat (limited to 'test/modules')
-rw-r--r--test/modules/metadata.test.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/modules/metadata.test.js b/test/modules/metadata.test.js
new file mode 100644
index 0000000..139de60
--- /dev/null
+++ b/test/modules/metadata.test.js
@@ -0,0 +1,33 @@
+const test = require('ava')
+const path = require('path')
+
+const metadata = require('../../src/modules/metadata.js')
+
+test('getFileMetadata', t => {
+  const expected = new Map(
+    Object.entries({
+      title: 'This is a test',
+      description: 'Test file',
+      tags: ['a', 'b']
+    })
+  )
+  t.deepEqual(
+    metadata.getFileMetadata(path.resolve(__dirname, '../data/testfile.md')),
+    expected
+  )
+})
+
+test('getFolderMetadata', t => {
+  const expected = new Map(
+    Object.entries({
+      title: 'This is a test',
+      description: 'Test file',
+      tags: ['a', 'b']
+    })
+  )
+  const actual = metadata.getFolderMetadata(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)
+})