Skip to content

Commit 3af26c7

Browse files
committed
test(cli): add coverage for CLI decimal and scientific number strings
1 parent 82f6369 commit 3af26c7

1 file changed

Lines changed: 102 additions & 0 deletions

File tree

test/Cli.basictest.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,108 @@ describe("Cli", () => {
279279
`)
280280
);
281281

282+
test(
283+
"numbers decimal and scientific notation strings",
284+
{
285+
"watch-options-aggregate-timeout": ".25",
286+
"watch-options-poll": "1e2",
287+
"output-chunk-load-timeout": "5.",
288+
parallelism: "1e+2",
289+
"performance-max-asset-size": "1.5e3",
290+
"performance-max-entrypoint-size": "2e-1",
291+
"stats-assets-space": "10E+1",
292+
"stats-errors-space": "+.5"
293+
},
294+
{},
295+
(e) =>
296+
e.toMatchInlineSnapshot(`
297+
Object {
298+
"output": Object {
299+
"chunkLoadTimeout": 5,
300+
},
301+
"parallelism": 100,
302+
"performance": Object {
303+
"maxAssetSize": 1500,
304+
"maxEntrypointSize": 0.2,
305+
},
306+
"stats": Object {
307+
"assetsSpace": 100,
308+
"errorsSpace": 0.5,
309+
},
310+
"watchOptions": Object {
311+
"aggregateTimeout": 0.25,
312+
"poll": 100,
313+
},
314+
}
315+
`)
316+
);
317+
318+
test(
319+
"invalid number strings (decimal and exponent edge cases)",
320+
{
321+
parallelism: "1e",
322+
"performance-max-asset-size": "e10",
323+
"performance-max-entrypoint-size": "1e2.5",
324+
"stats-assets-space": "1.2.3",
325+
"output-chunk-load-timeout": "7e-",
326+
"stats-warnings-space": "++1"
327+
},
328+
{},
329+
(e) =>
330+
e.toMatchInlineSnapshot(`
331+
Array [
332+
Object {
333+
"argument": "parallelism",
334+
"expected": "number",
335+
"index": undefined,
336+
"path": "parallelism",
337+
"type": "invalid-value",
338+
"value": "1e",
339+
},
340+
Object {
341+
"argument": "performance-max-asset-size",
342+
"expected": "number",
343+
"index": undefined,
344+
"path": "performance.maxAssetSize",
345+
"type": "invalid-value",
346+
"value": "e10",
347+
},
348+
Object {
349+
"argument": "performance-max-entrypoint-size",
350+
"expected": "number",
351+
"index": undefined,
352+
"path": "performance.maxEntrypointSize",
353+
"type": "invalid-value",
354+
"value": "1e2.5",
355+
},
356+
Object {
357+
"argument": "stats-assets-space",
358+
"expected": "number",
359+
"index": undefined,
360+
"path": "stats.assetsSpace",
361+
"type": "invalid-value",
362+
"value": "1.2.3",
363+
},
364+
Object {
365+
"argument": "output-chunk-load-timeout",
366+
"expected": "number",
367+
"index": undefined,
368+
"path": "output.chunkLoadTimeout",
369+
"type": "invalid-value",
370+
"value": "7e-",
371+
},
372+
Object {
373+
"argument": "stats-warnings-space",
374+
"expected": "number",
375+
"index": undefined,
376+
"path": "stats.warningsSpace",
377+
"type": "invalid-value",
378+
"value": "++1",
379+
},
380+
]
381+
`)
382+
);
383+
282384
test(
283385
"booleans and enums",
284386
{

0 commit comments

Comments
 (0)