From bf20f4f6d97b8d2643f19ed7ac617c33a7f2ea6b Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 18 Jun 2017 12:35:49 +0200 Subject: refactor: metadata -> posts --- test/modules/metadata.test.js | 33 --------------------------------- test/modules/posts.test.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 33 deletions(-) delete mode 100644 test/modules/metadata.test.js create mode 100644 test/modules/posts.test.js (limited to 'test/modules') diff --git a/test/modules/metadata.test.js b/test/modules/metadata.test.js deleted file mode 100644 index f154eac..0000000 --- a/test/modules/metadata.test.js +++ /dev/null @@ -1,33 +0,0 @@ -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'] - }) - ) - const meta = metadata.getFileMetadata( - path.resolve(__dirname, '../data/testfile.md') - ) - t.deepEqual(meta.data, 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) -}) 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) +}) -- cgit 1.4.1