cheerio-util.js
1.13 KB
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
/*eslint-env mocha*/
/*eslint no-undefined:0*/
/*jshint -W100*/
var assert = require('power-assert');
var cutil = require('../lib/cheerio/util');
describe('cheerio:util', function () {
describe('inArray', function () {
it('配列内に該当あり => true', function () {
assert(cutil.inArray([ 'foo', 'bar', 'baz' ], 'foo') === true);
});
it('配列内に該当なし => false', function () {
assert(cutil.inArray([ 'foo', 'bar', 'baz' ], 'boo') === false);
});
it('配列以外 => 例外発生', function () {
try {
cutil.inArray('hoge', 'boo');
throw new Error('not thrown');
} catch (e) {
assert(e.message === 'hoge is not Array');
}
});
});
describe('paramFilter', function () {
it('文字列 => そのまま返す', function () {
assert(cutil.paramFilter('hoge') === 'hoge');
});
it('0 => そのまま返す', function () {
assert(cutil.paramFilter(0) === 0);
});
it('null/undefined => 空文字を返す', function () {
assert(cutil.paramFilter(null) === '');
assert(cutil.paramFilter(undefined) === '');
});
});
});