Skip to content

Commit 42b2f62

Browse files
committed
test: add alias tests for util.styleText
1 parent f292939 commit 42b2f62

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/parallel/test-util-styletext.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,29 @@ assert.throws(() => {
154154
code: 'ERR_INVALID_ARG_TYPE',
155155
});
156156

157+
// Color aliases should be accepted (e.g. 'grey' is an alias for 'gray')
158+
// See https://github.com/nodejs/node/issues/62177
159+
assert.strictEqual(
160+
util.styleText('grey', 'test', { validateStream: false }),
161+
util.styleText('gray', 'test', { validateStream: false }),
162+
);
163+
assert.strictEqual(
164+
util.styleText('bgGrey', 'test', { validateStream: false }),
165+
util.styleText('bgGray', 'test', { validateStream: false }),
166+
);
167+
assert.strictEqual(
168+
util.styleText('blackBright', 'test', { validateStream: false }),
169+
util.styleText('gray', 'test', { validateStream: false }),
170+
);
171+
assert.strictEqual(
172+
util.styleText('faint', 'test', { validateStream: false }),
173+
util.styleText('dim', 'test', { validateStream: false }),
174+
);
175+
assert.strictEqual(
176+
util.styleText(['grey', 'bold'], 'test', { validateStream: false }),
177+
util.styleText(['gray', 'bold'], 'test', { validateStream: false }),
178+
);
179+
157180
// does not throw
158181
util.styleText('red', 'text', { stream: {}, validateStream: false });
159182

0 commit comments

Comments
 (0)