-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! errors: fix ERR_UNSUPPORTED_ESM_URL_SCHEME error message
Signed-off-by: Daeyeon Jeong <[email protected]> Co-authored-by: Antoine du Hamel <[email protected]>
- Loading branch information
Showing
1 changed file
with
12 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,18 @@ | ||
// Flags: --expose-internals | ||
'use strict'; | ||
|
||
require('../common'); | ||
const common = require('../common'); | ||
const { strictEqual } = require('node:assert'); | ||
const { formatList } = require('internal/errors'); | ||
|
||
strictEqual(formatList([]), ''); | ||
|
||
strictEqual(formatList([], 'or'), ''); | ||
|
||
strictEqual(formatList(['apple']), 'apple'); | ||
|
||
strictEqual(formatList(['apple'], 'or'), 'apple'); | ||
|
||
strictEqual(formatList(['apple', 'banana']), 'apple and banana'); | ||
|
||
strictEqual(formatList(['apple', 'banana'], 'or'), 'apple or banana'); | ||
|
||
strictEqual( | ||
formatList(['apple', 'banana', 'orange']), | ||
'apple, banana, and orange' | ||
); | ||
|
||
strictEqual( | ||
formatList(['apple', 'banana', 'orange'], 'or'), | ||
'apple, banana, or orange' | ||
); | ||
if (common.hasIntl) { | ||
const and = new Intl.ListFormat('en', { style: 'long', type: 'conjunction' }); | ||
const or = new Intl.ListFormat('en', { style: 'long', type: 'disjunction' }); | ||
|
||
const input = ['apple', 'banana', 'orange']; | ||
for (let i = 0; i < input.length; i++) { | ||
const slicedInput = input.slice(0, i); | ||
strictEqual(formatList(slicedInput), and.format(slicedInput)); | ||
strictEqual(formatList(slicedInput, 'or'), or.format(slicedInput)); | ||
} | ||
} |