Skip to content

Commit d00afbd

Browse files
authored
Fix error symbol (#36)
1 parent a2389bb commit d00afbd

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

symbols.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ const _isUnicodeSupported = isUnicodeSupported();
1111
export const info = blue(_isUnicodeSupported ? 'ℹ' : 'i');
1212
export const success = green(_isUnicodeSupported ? '✔' : '√');
1313
export const warning = yellow(_isUnicodeSupported ? '⚠' : '‼');
14-
export const error = red(_isUnicodeSupported ? '✖' : '×');
14+
export const error = red(_isUnicodeSupported ? '✖' : '×');

test.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@ import test from 'ava';
22
import stripAnsi from 'strip-ansi';
33
import logSymbols from './index.js';
44

5-
for (const [key, value] of Object.entries(logSymbols)) {
6-
console.log(value, key);
7-
}
8-
9-
console.log('');
5+
const symbols = Object.entries(logSymbols)
6+
.map(([key, value]) => `${value} ${key}`)
7+
.join('\n');
108

119
test('returns log symbols', t => {
10+
t.true(stripAnsi(logSymbols.info) === 'ℹ' || stripAnsi(logSymbols.info) === 'i');
1211
t.true(stripAnsi(logSymbols.success) === '✔' || stripAnsi(logSymbols.success) === '√');
12+
t.true(stripAnsi(logSymbols.warning) === '⚠' || stripAnsi(logSymbols.warning) === '‼');
13+
t.true(stripAnsi(logSymbols.error) === '✖' || stripAnsi(logSymbols.error) === '×');
14+
t.log(symbols);
15+
});
16+
17+
test('confirms Unicode code point for log symbols', t => {
18+
const infoCodePoint = stripAnsi(logSymbols.info).codePointAt(0);
19+
const successCodePoint = stripAnsi(logSymbols.success).codePointAt(0);
20+
const warningCodePoint = stripAnsi(logSymbols.warning).codePointAt(0);
21+
const errorCodePoint = stripAnsi(logSymbols.error).codePointAt(0);
22+
23+
t.true(infoCodePoint === 8505 || infoCodePoint === 105);
24+
t.true(successCodePoint === 10_004 || successCodePoint === 8730);
25+
t.true(warningCodePoint === 9888 || warningCodePoint === 8252);
26+
t.true(errorCodePoint === 10_006 || errorCodePoint === 215);
1327
});

0 commit comments

Comments
 (0)