Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function substringAfterLast( str, search, fromIndex ) {
}
if ( arguments.length > 2 ) {
if ( !isInteger( fromIndex ) ) {
throw new TypeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%s`.', fromIndex ) );
throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', fromIndex ) );
}
idx = str.lastIndexOf( search, fromIndex );
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ tape( 'the function throws an error if not provided a string as its second argum
}
});

tape( 'the function throws an error if the start index is not an integer', function test( t ) {
t.throws( badValue, /Third argument must be an integer\./, 'reports that the start index must be an integer' );
t.end();

function badValue() {
substringAfterLast( 'beep', 'b', -1.5 );
}
});

tape( 'the function returns the substring after the last occurrence of a provided search string', function test( t ) {
var expected;
var actual;
Expand Down
Loading