Skip to content

Commit 7dfe416

Browse files
committed
test: add tests to @stdlib/string/format-interpolate
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 350c422 commit 7dfe416

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

lib/node_modules/@stdlib/string/base/format-interpolate/test/test.format_integer.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,49 @@ tape( 'the function returns an integer-formatted token argument (precision)', fu
168168

169169
t.end();
170170
});
171+
172+
tape( 'the function throws an error for non-numeric input', function test( t ) {
173+
var token;
174+
175+
token = {
176+
'specifier': 'd',
177+
'arg': 'abc'
178+
};
179+
180+
t.throws(function util() {
181+
formatInteger( token );
182+
}, Error, 'returns expected error' );
183+
184+
t.end();
185+
});
186+
187+
tape( 'the function coerces non-finite numeric input to empty string', function test( t ) {
188+
var expected;
189+
var actual;
190+
var token;
191+
192+
expected = '';
193+
194+
token = {
195+
'specifier': 'd',
196+
'arg': NaN
197+
};
198+
actual = formatInteger( token );
199+
t.strictEqual( actual, expected, 'returns expected empty string' );
200+
201+
token = {
202+
'specifier': 'd',
203+
'arg': Infinity
204+
};
205+
actual = formatInteger( token );
206+
t.strictEqual( actual, expected, 'returns expected empty string' );
207+
208+
token = {
209+
'specifier': 'd',
210+
'arg': -Infinity
211+
};
212+
actual = formatInteger( token );
213+
t.strictEqual( actual, expected, 'returns expected empty string' );
214+
215+
t.end();
216+
});

0 commit comments

Comments
 (0)