Skip to content

Commit 288c5b1

Browse files
committed
test: add test case
1 parent 2249ebe commit 288c5b1

File tree

1 file changed

+27
-0
lines changed
  • lib/node_modules/@stdlib/string/first/test

1 file changed

+27
-0
lines changed

lib/node_modules/@stdlib/string/first/test/test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,33 @@ tape( 'the function throws an error if not provided a string', function test( t
5959
}
6060
});
6161

62+
tape( 'the function throws an error if not provided a string (options)', function test( t ) {
63+
var values;
64+
var i;
65+
66+
values = [
67+
5,
68+
null,
69+
true,
70+
void 0,
71+
NaN,
72+
[],
73+
{},
74+
function noop() {}
75+
];
76+
77+
for ( i = 0; i < values.length; i++ ) {
78+
t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
79+
}
80+
t.end();
81+
82+
function badValue( value ) {
83+
return function badValue() {
84+
first( value, {} );
85+
};
86+
}
87+
});
88+
6289
tape( 'the function throws an error if provided a second argument which is not a nonnegative integer', function test( t ) {
6390
var values;
6491
var i;

0 commit comments

Comments
 (0)