test: enforce coverage thresholds
This commit is contained in:
+44
-1
@@ -1,7 +1,18 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { labelPrefix, resolveOutputConfigFromArgv, statusPrefix } from '../src/lib/output.js';
|
||||
import {
|
||||
formatStatsLine,
|
||||
labelPrefix,
|
||||
resolveOutputConfigFromArgv,
|
||||
resolveOutputConfigFromCommander,
|
||||
statusPrefix,
|
||||
} from '../src/lib/output.js';
|
||||
|
||||
describe('output', () => {
|
||||
it('defaults to emoji + color on TTY', () => {
|
||||
const cfg = resolveOutputConfigFromArgv([], {}, true);
|
||||
expect(cfg).toEqual({ plain: false, emoji: true, color: true });
|
||||
});
|
||||
|
||||
it('plain disables emoji + color', () => {
|
||||
const cfg = resolveOutputConfigFromArgv(['--plain'], {}, true);
|
||||
expect(cfg).toEqual({ plain: true, emoji: false, color: false });
|
||||
@@ -14,9 +25,41 @@ describe('output', () => {
|
||||
expect(cfg.color).toBe(false);
|
||||
});
|
||||
|
||||
it('TERM=dumb disables colors by default', () => {
|
||||
const cfg = resolveOutputConfigFromArgv([], { TERM: 'dumb' }, true);
|
||||
expect(cfg.color).toBe(false);
|
||||
});
|
||||
|
||||
it('--no-color disables colors', () => {
|
||||
const cfg = resolveOutputConfigFromArgv(['--no-color'], {}, true);
|
||||
expect(cfg).toEqual({ plain: false, emoji: true, color: false });
|
||||
});
|
||||
|
||||
it('--no-emoji switches to text prefixes', () => {
|
||||
const cfg = resolveOutputConfigFromArgv(['--no-emoji'], {}, true);
|
||||
expect(cfg.emoji).toBe(false);
|
||||
expect(statusPrefix('warn', cfg)).toBe('Warning: ');
|
||||
});
|
||||
|
||||
it('commander opts override defaults', () => {
|
||||
const cfg = resolveOutputConfigFromCommander({ emoji: false, color: false }, {}, true);
|
||||
expect(cfg).toEqual({ plain: false, emoji: false, color: false });
|
||||
expect(statusPrefix('info', cfg)).toBe('Info: ');
|
||||
expect(labelPrefix('date', cfg)).toBe('Date: ');
|
||||
});
|
||||
|
||||
it('commander plain wins over emoji/color', () => {
|
||||
const cfg = resolveOutputConfigFromCommander({ plain: true, emoji: true, color: true }, {}, true);
|
||||
expect(cfg).toEqual({ plain: true, emoji: false, color: false });
|
||||
});
|
||||
|
||||
it('formats stats line for all modes', () => {
|
||||
const stats = { likeCount: null, retweetCount: undefined, replyCount: 2 };
|
||||
|
||||
expect(formatStatsLine(stats, { plain: true, emoji: false, color: false })).toBe(
|
||||
'likes: 0 retweets: 0 replies: 2',
|
||||
);
|
||||
expect(formatStatsLine(stats, { plain: false, emoji: false, color: false })).toBe('Likes 0 Retweets 0 Replies 2');
|
||||
expect(formatStatsLine(stats, { plain: false, emoji: true, color: false })).toBe('❤️ 0 🔁 0 💬 2');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user