Skip to content

Commit

Permalink
Add unit tests for line counter (#1444)
Browse files Browse the repository at this point in the history
I'm curious if not using `require('os').EOL` for splitting lines in lineCounter is problematic or not. Since I don't have a Windows machine I'm testing this in your CI! :D
  • Loading branch information
mohsen1 authored and Jasper De Moor committed May 27, 2018
1 parent d3e04b5 commit dc11325
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 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);
});
});

0 comments on commit dc11325

Please sign in to comment.