-
Notifications
You must be signed in to change notification settings - Fork 56
/
test.js
68 lines (57 loc) · 2.76 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const test = require('ava');
const mcc_mnc_list = require('./index');
test( 'all()', t => {
t.is( typeof mcc_mnc_list.all, 'function' );
t.truthy( Array.isArray( mcc_mnc_list.all() ) );
t.truthy( mcc_mnc_list.all().length > 0 );
} );
test( 'statusCodes()', t => {
t.is( typeof mcc_mnc_list.statusCodes, 'function' );
t.truthy( Array.isArray( mcc_mnc_list.statusCodes() ) );
t.truthy( mcc_mnc_list.statusCodes().length > 0 );
} );
test( 'filter()', t => {
t.is( typeof mcc_mnc_list.filter, 'function' );
t.truthy( Array.isArray( mcc_mnc_list.filter() ) );
t.truthy( mcc_mnc_list.filter().length > 0 );
t.truthy( mcc_mnc_list.filter({}).length > 0 );
} );
test( 'filter() not object parameter exceptions', t => {
t.throws( function () { return mcc_mnc_list.filter(1); } );
t.throws( function () { return mcc_mnc_list.filter(''); } );
} );
test( 'filter() status code', t => {
t.truthy( Array.isArray( mcc_mnc_list.filter({ statusCode: 'Operational' }) ) );
t.throws( function () { return mcc_mnc_list.filter({ statusCode: 'NotExistentStatusCode' }); } );
} );
test( 'filter() mcc', t => {
t.truthy( Array.isArray( mcc_mnc_list.filter({ mcc: '216' }) ) );
t.truthy( Array.isArray( mcc_mnc_list.filter({ mcc: 216 }) ) );
t.throws( function () { return mcc_mnc_list.filter({ mcc: {} }); } );
} );
test( 'filter() mnc', t => {
t.truthy( Array.isArray( mcc_mnc_list.filter({ mnc: '30' }) ) );
t.truthy( Array.isArray( mcc_mnc_list.filter({ mnc: 30 }) ) );
t.throws( function () { return mcc_mnc_list.filter({ mnc: {} }); } );
} );
test( 'filter() mccmnc', t => {
t.truthy( Array.isArray( mcc_mnc_list.filter({ mccmnc: '21630' }) ) );
t.truthy( Array.isArray( mcc_mnc_list.filter({ mccmnc: 21630 }) ) );
t.throws( function () { return mcc_mnc_list.filter({ mccmnc: {} }); } );
t.throws( function () { return mcc_mnc_list.filter({ mccmnc: '21630', mcc: '216' }); } );
t.throws( function () { return mcc_mnc_list.filter({ mccmnc: '21630', mnc: '30' }); } );
} );
test( 'filter() mcc, mnc', t => {
t.truthy( Array.isArray( mcc_mnc_list.filter({ mcc: '216', mnc: '30' }) ) );
t.truthy( Array.isArray( mcc_mnc_list.filter({ mcc: 216, mnc: 30 }) ) );
t.truthy( mcc_mnc_list.filter({ mcc: '216', mnc: '30' }).length === 1 );
} );
test( 'filter() country code should be a string', t => {
t.throws( function () { return mcc_mnc_list.filter({ countryCode: 0 }); } );
t.throws( function () { return mcc_mnc_list.filter({ countryCode: {} }); } );
} );
test( 'filter() country code', t => {
t.truthy( Array.isArray( mcc_mnc_list.filter({ countryCode: 'US' }) ) );
t.truthy( Array.isArray( mcc_mnc_list.filter({ statusCode: 'Operational', countryCode: 'US' }) ) );
t.truthy( mcc_mnc_list.filter({ statusCode: 'Operational', countryCode: 'US' }).length > 1 );
} );