mirror of
https://github.com/scratchfoundation/scratch-analysis.git
synced 2024-11-28 02:25:45 -05:00
Clean-up utility module / tests
This commit is contained in:
parent
b164232b3f
commit
f95001ffec
2 changed files with 20 additions and 1 deletions
|
@ -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
|
||||
*/
|
||||
|
|
19
test/unit/utility.js
Normal file
19
test/unit/utility.js
Normal file
|
@ -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();
|
||||
});
|
Loading…
Reference in a new issue