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 11, 2019
1 parent ac25059 commit 8cfc79b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -24,7 +24,8 @@
"bull": "^3.11.0",
"dotenv": "^8.2.0",
"feedparser-promised": "^2.0.1",
"sentiment": "^5.0.2"
"sentiment": "^5.0.2",
"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 wordCounter(blogText) {
return Promise.resolve(wordcount(blogText));
};
5 changes: 5 additions & 0 deletions test/word-counter.test.js
@@ -0,0 +1,5 @@
const { wordCounter } = require('../src/word-counter');

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

0 comments on commit 8cfc79b

Please sign in to comment.