Skip to content

Commit c9acefd

Browse files
committed
Add suffix-only tests
1 parent 4588137 commit c9acefd

File tree

2 files changed

+126
-3
lines changed

2 files changed

+126
-3
lines changed

lib/node_modules/@stdlib/nlp/ordinalize/docs/repl.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,18 @@
1111
Options.
1212

1313
options.lang: string (optional)
14-
Language code. Default: `'en'`.
14+
Language code. Supported languages:
15+
16+
- en: English.
17+
- es: Spanish.
18+
- fin: Finnish.
19+
- fr: French.
20+
- de: Dutch.
21+
- it: Italian.
22+
- pt: Portuguese.
23+
- swe: Swedish.
24+
25+
Default: `'en'`.
1526

1627
options.suffixOnly: boolean (optional)
1728
Boolean indicating whether to return only the suffix. Default: `false`.

lib/node_modules/@stdlib/nlp/ordinalize/test/test.js

Lines changed: 114 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,120 @@ tape( 'the function returns an ordinal string for a provided integer (default la
248248
t.end();
249249
});
250250

251+
tape( 'the function supports returning an ordinal string suffix for a provided integer string (default language)', function test( t ) {
252+
var expected;
253+
var values;
254+
var opts;
255+
var i;
256+
257+
values = [
258+
'1',
259+
'2',
260+
'21',
261+
'7',
262+
'10',
263+
'11',
264+
'12',
265+
'13',
266+
'14',
267+
'15',
268+
'16',
269+
'21',
270+
'22',
271+
'23',
272+
'24',
273+
'332',
274+
'333',
275+
'999'
276+
];
277+
expected = [
278+
'st',
279+
'nd',
280+
'st',
281+
'th',
282+
'th',
283+
'th',
284+
'th',
285+
'th',
286+
'th',
287+
'th',
288+
'th',
289+
'st',
290+
'nd',
291+
'rd',
292+
'th',
293+
'nd',
294+
'rd',
295+
'th'
296+
];
297+
298+
opts = {
299+
'suffixOnly': true
300+
};
301+
302+
for ( i = 0; i < values.length; i++ ) {
303+
t.equal( ordinalize( values[i], opts ), expected[i], 'returns expected value' );
304+
}
305+
t.end();
306+
});
307+
308+
tape( 'the function supports returning an ordinal string suffix for a provided integer (default language)', function test( t ) {
309+
var expected;
310+
var values;
311+
var opts;
312+
var i;
313+
314+
values = [
315+
1,
316+
2,
317+
21,
318+
7,
319+
10,
320+
11,
321+
12,
322+
13,
323+
14,
324+
15,
325+
16,
326+
21,
327+
22,
328+
23,
329+
24,
330+
332,
331+
333,
332+
999
333+
];
334+
expected = [
335+
'st',
336+
'nd',
337+
'st',
338+
'th',
339+
'th',
340+
'th',
341+
'th',
342+
'th',
343+
'th',
344+
'th',
345+
'th',
346+
'st',
347+
'nd',
348+
'rd',
349+
'th',
350+
'nd',
351+
'rd',
352+
'th'
353+
];
354+
355+
opts = {
356+
'suffixOnly': true
357+
};
358+
359+
for ( i = 0; i < values.length; i++ ) {
360+
t.equal( ordinalize( values[i], opts ), expected[i], 'returns expected value' );
361+
}
362+
t.end();
363+
});
364+
251365
tape( 'the function returns an ordinal string for a provided integer string (lang=en)', function test( t ) {
252366
var expected;
253367
var values;
@@ -1224,5 +1338,3 @@ tape( 'the function returns an ordinal string for a provided integer string (lan
12241338
}
12251339
t.end();
12261340
});
1227-
1228-
// FIXME: add suffix only tests

0 commit comments

Comments
 (0)