diff options
author | Alan Pearce | 2017-06-24 22:05:18 +0200 |
---|---|---|
committer | Alan Pearce | 2017-06-24 22:05:18 +0200 |
commit | dd819c45b58088f9a98384ab237268d865836fe0 (patch) | |
tree | abf2c2847571041454a9119dff7ccfc6b7d0f854 /test | |
parent | bdd6610208e9fe5971e6aed4378598092f2b9b5a (diff) | |
download | homestead-dd819c45b58088f9a98384ab237268d865836fe0.tar.lz homestead-dd819c45b58088f9a98384ab237268d865836fe0.tar.zst homestead-dd819c45b58088f9a98384ab237268d865836fe0.zip |
refactor: re-architect to be closer to ADR
Diffstat (limited to 'test')
-rw-r--r-- | test/domain/posts.test.js | 23 | ||||
-rw-r--r-- | test/modules/posts.test.js | 49 |
2 files changed, 23 insertions, 49 deletions
diff --git a/test/domain/posts.test.js b/test/domain/posts.test.js new file mode 100644 index 0000000..8866f40 --- /dev/null +++ b/test/domain/posts.test.js @@ -0,0 +1,23 @@ +const test = require('ava') +const path = require('path') + +const Posts = require('../../src/domain/posts.js')({ + folder: path.resolve('../data', __dirname), + taxonomies: { + tag: 'tags', + category: 'categories' + } +}) + +test('get', t => { + const expected = new Map( + Object.entries({ + title: 'This is a test', + description: 'Test file', + tags: ['a', 'b'] + }) + ) + const post = Posts.get(path.resolve(__dirname, '../data/testfile.md')) + t.deepEqual(post.data, expected) + t.is(post.basename, 'testfile', 'must include basename') +}) diff --git a/test/modules/posts.test.js b/test/modules/posts.test.js deleted file mode 100644 index 454488f..0000000 --- a/test/modules/posts.test.js +++ /dev/null @@ -1,49 +0,0 @@ -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 post = Posts.get(path.resolve(__dirname, '../data/testfile.md')) - t.deepEqual(post.data, expected) - t.is(post.basename, 'testfile', 'must include basename') -}) - -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(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) -}) - -test('toTags', t => { - const posts = new Map([ - [ - 'testfile', - { - data: new Map([['title', 'Test Post'], ['tags', ['a', 'b']]]) - } - ] - ]) - const actual = Posts.toTags(posts) - t.is(actual.size, 2) - t.is(actual.get('a')[0].data.get('title'), 'Test Post') - t.deepEqual(actual.get('a'), actual.get('b')) -}) |