diff --git a/test/lineCounter.js b/test/lineCounter.js new file mode 100644 index 00000000000..5d2e59a26ff --- /dev/null +++ b/test/lineCounter.js @@ -0,0 +1,18 @@ +const fs = require('fs'); +const assert = require('assert'); +const lineCounter = require('../src/utils/lineCounter'); + +describe('line counter', () => { + it('counts number of lines of a string', () => { + const input = ` line 1 + line 2 + line 3`; + + assert(lineCounter(input) === 3); + }); + + it('counts number of lines of a file from disk', () => { + const input = fs.readFileSync('./test/lineCounter.js').toString(); + assert(lineCounter(input) === 19); + }); +});