|
- import wrapAnsi from 'wrap-ansi';
- import {
- afterAll,
- beforeAll,
- describe,
- expect,
- it, SpyInstanceFn,
- vi,
- } from 'vitest';
- import card from '../card';
-
- vi.mock('wrap-ansi');
-
- describe('card', () => {
- let log: SpyInstanceFn<[], void>;
-
- let defaultConsole: typeof console;
- beforeAll(() => {
- defaultConsole = console;
- log = vi.fn();
- global.console = {
- log,
- } as unknown as typeof console;
- });
-
- afterAll(() => {
- global.console = defaultConsole;
- });
-
- it('calls wrap', async () => {
- await card()('foo');
- expect(wrapAnsi).toBeCalled();
- });
-
- it('calls the console output function', async () => {
- await card()('foo');
- expect(log).toBeCalled();
- });
- });
|