Skip to content

Commit

Permalink
Implemented basic word counter & test (Seneca-CDOT#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
birtony committed Nov 7, 2019
1 parent 163f2d0 commit 7541194
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -17,7 +17,8 @@
"homepage": "https://github.com/Seneca-CDOT/telescope#readme",
"dependencies": {
"bent": "^7.0.2",
"bull": "^3.11.0"
"bull": "^3.11.0",
"wordcount": "^1.1.1"
},
"devDependencies": {
"eslint": "^6.6.0",
Expand Down
5 changes: 5 additions & 0 deletions src/word-counter.js
@@ -0,0 +1,5 @@
const wordcount = require('wordcount');

exports.wordCounter = async function(blogText) {
return Promise.resolve(wordcount(blogText));
};
7 changes: 7 additions & 0 deletions test/word-counter.test.js
@@ -0,0 +1,7 @@
const { wordCounter } = require('../src/word-counter');

test('counts the number of words in a 5-word long sentence', () => {
return wordCounter('one two three four five').then(data => {
expect(data).toBe(5);
});
});

0 comments on commit 7541194

Please sign in to comment.