-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
42 lines (34 loc) · 1.08 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
36
37
38
39
40
41
42
/*!
* clean-tostring <https://github.com/tunnckoCore/clean-tostring>
*
* Copyright (c) 2016 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)
* Released under the MIT license.
*/
/* jshint asi:true */
'use strict'
var test = require('assertit')
var cleanTostring = require('./index')
var isIstanbul = process.env.running_under_istanbul
test('should throw TypeError if `val` not a function', function (done) {
function fixture () {
cleanTostring(123)
}
test.throws(fixture, TypeError)
test.throws(fixture, /expect `fn` be function/)
done()
})
test('should clean coverage code from function toString', function (done) {
/* istanbul ignore next */
function fixture (a) {
if (typeof a === 'string') {
return a
}
return false
}
var actual = cleanTostring(fixture)
var expected = isIstanbul
? 'function fixture(a) {if(typeof a===\'string\'){return a;}else{}return false;}'
: 'function fixture(a) {\n if (typeof a === \'string\') {\n return a\n }\n return false\n }'
test.strictEqual(actual, expected)
done()
})