summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/data/testfile.md1
-rw-r--r--test/index.test.js10
-rw-r--r--test/modules/posts.test.js10
3 files changed, 16 insertions, 5 deletions
diff --git a/test/data/testfile.md b/test/data/testfile.md
index 6899d52..bafc456 100644
--- a/test/data/testfile.md
+++ b/test/data/testfile.md
@@ -3,3 +3,4 @@ Title = "This is a test"
 Description = "Test file"
 Tags = ["a", "b"]
 +++
+# Lorem ipsum
diff --git a/test/index.test.js b/test/index.test.js
index ebac87d..897438c 100644
--- a/test/index.test.js
+++ b/test/index.test.js
@@ -5,7 +5,7 @@ const request = require('supertest')
 process.env.POST_DIR = path.resolve(__dirname, '../test/data/')
 const app = require('../src/index.js')
 
-test(t => {
+test('homepage', t => {
   return request(app.listen())
     .get('/')
     .expect(200)
@@ -13,3 +13,11 @@ test(t => {
     .expect(/This is a test/)
     .then(() => t.pass())
 })
+
+test('post', t => {
+  return request(app.listen())
+    .get('/post/testfile')
+    .expect(200)
+    .expect(/Lorem ipsum/)
+    .then(() => t.pass())
+})
diff --git a/test/modules/posts.test.js b/test/modules/posts.test.js
index 28a25f2..cdbf22a 100644
--- a/test/modules/posts.test.js
+++ b/test/modules/posts.test.js
@@ -24,8 +24,10 @@ test('getFolder', t => {
     })
   )
   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)
+  t.true(actual.size > 0, 'must return a non-empty map')
+  t.is(
+    actual.get('testfile').path,
+    path.resolve(__dirname, '../data/testfile.md')
+  )
+  t.deepEqual(actual.get('testfile').data, expected)
 })