diff --git a/lib/node_modules/@stdlib/string/base/format-interpolate/test/test.format_integer.js b/lib/node_modules/@stdlib/string/base/format-interpolate/test/test.format_integer.js index 9242698bc7ef..95e59b4fa73f 100644 --- a/lib/node_modules/@stdlib/string/base/format-interpolate/test/test.format_integer.js +++ b/lib/node_modules/@stdlib/string/base/format-interpolate/test/test.format_integer.js @@ -168,3 +168,53 @@ tape( 'the function returns an integer-formatted token argument (precision)', fu t.end(); }); + +tape( 'the function throws an error for non-numeric input', function test( t ) { + var token; + + token = { + 'specifier': 'd', + 'arg': 'abc' + }; + + t.throws( badToken( token ), Error, 'throws an error when provided arg '+token.arg ); + + t.end(); + + function badToken( token ) { + return function badToken() { + formatInteger( token ); + }; + } +}); + +tape( 'the function coerces non-finite numeric input to empty string', function test( t ) { + var expected; + var actual; + var token; + + expected = ''; + + token = { + 'specifier': 'd', + 'arg': NaN + }; + actual = formatInteger( token ); + t.strictEqual( actual, expected, 'returns expected empty string' ); + + token = { + 'specifier': 'd', + 'arg': Infinity + }; + actual = formatInteger( token ); + t.strictEqual( actual, expected, 'returns expected empty string' ); + + token = { + 'specifier': 'd', + 'arg': -Infinity + }; + actual = formatInteger( token ); + t.strictEqual( actual, expected, 'returns expected empty string' ); + + t.end(); +});