-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
35 lines (30 loc) · 1.3 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict'
var test = require('tape')
var sloccount = require('./')
var fs = require('fs')
test('can count get lines of the index.js file (without comments)', function (t) {
t.plan(4)
sloccount({src: './index.js', reportPath: 'stats/report.sc', comments: false, verbose: false})
var contents = fs.readFileSync('stats/report.sc', 'utf-8')
t.equal(contents.indexOf('Categorizing files.') !== -1, true)
t.equal(contents.indexOf('Computing results.') !== -1, true)
t.equal(contents.indexOf('57 js') !== -1, true)
t.equal(contents.indexOf('sloccount/index.js') !== -1, true)
})
test('can count get lines of the index.js file (with comments)', function (t) {
t.plan(6)
sloccount({src: './index.js', reportPath: 'stats/report.sc', comments: true, verbose: false})
var contents = fs.readFileSync('stats/report.sc', 'utf-8')
t.equal(contents.indexOf('Categorizing files.') !== -1, true)
t.equal(contents.indexOf('Computing results.') !== -1, true)
t.equal(contents.indexOf('57 js') !== -1, true)
t.equal(contents.indexOf('sloccount/index.js') !== -1, true)
t.equal(contents.indexOf('14 jscm') !== -1, true)
t.equal(contents.indexOf('sloccount/index.js.cm') !== -1, true)
})
test('throws if no source directory is given', function (t) {
t.plan(1)
t.throws(function () {
sloccount()
}, Error)
})