From 0e2e2566b938dff9681aed535f355a1e9e725c17 Mon Sep 17 00:00:00 2001 From: Sam Harris Date: Wed, 31 Jul 2019 12:23:26 +0300 Subject: [PATCH] tests created for folderAssets function relates #8 --- src/utils.js | 9 +++++++++ tests/test.js | 14 ++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/utils.js diff --git a/src/utils.js b/src/utils.js new file mode 100644 index 0000000..d9f5fc2 --- /dev/null +++ b/src/utils.js @@ -0,0 +1,9 @@ +const fs = require('fs'); + +const folderContents = () => { + +}; + +module.exports = { + folderContents, +}; diff --git a/tests/test.js b/tests/test.js index 4611d6b..ef37fdc 100644 --- a/tests/test.js +++ b/tests/test.js @@ -1,6 +1,7 @@ const test = require('tape'); const supertest = require('supertest'); const router = require('../src/router.js'); +const utils = require('../src/utils.js'); test('check home status code is 200', (t) => { supertest(router) @@ -34,3 +35,16 @@ test('check home app.js status code is 200', (t) => { t.end(err); }); }); + +test('Check that assetsContents function is a pure function that returns array of objects', (t) => { + const folder = '../tests'; + const folderCheck = folder; + const actual = utils.folderContents(folder); + const expected = [{ + name: 'tests.js', + filepath: '/Users/samjam/Code/founders-and-coders/course/5-node-advanced/make-notes-project/tests/test.js', + }]; + t.deepEqual(actual, expected, 'returns array of correct objects'); + t.deepEqual(folder, folderCheck, 'does not mutate arguments passed to it'); + t.deepEqual(actual, expected, 'returns same result given same arguments'); +});