From f95001ffec83524391399a6c0c7ca57d9ab8987b Mon Sep 17 00:00:00 2001 From: Andrew Sliwinski Date: Mon, 17 Dec 2018 20:12:21 -0500 Subject: [PATCH] Clean-up utility module / tests --- lib/utility.js | 2 +- test/unit/utility.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/unit/utility.js diff --git a/lib/utility.js b/lib/utility.js index 6ef2bb4..cb83509 100644 --- a/lib/utility.js +++ b/lib/utility.js @@ -3,7 +3,7 @@ */ class Utility { /** - * Tallys term frequency from an array of strings. + * Tallies term frequency from an array of strings. * @param {array} input Array of strings * @return {object} Frequency information */ diff --git a/test/unit/utility.js b/test/unit/utility.js new file mode 100644 index 0000000..ee220bd --- /dev/null +++ b/test/unit/utility.js @@ -0,0 +1,19 @@ +const test = require('tap').test; +const utility = require('../../lib/utility'); + +test('spec', t => { + t.type(utility, 'function'); + t.type(utility.frequency, 'function'); + t.end(); +}); + +test('frequency', t => { + const input = ['foo', 'foo', 'foo', 'bar', 'bar', 'baz']; + const result = utility.frequency(input); + t.deepEqual(result, { + foo: 3, + bar: 2, + baz: 1 + }); + t.end(); +});