CLI for Oblique Strategies.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
716 B

  1. import wrapAnsi from 'wrap-ansi';
  2. import {
  3. afterAll,
  4. beforeAll,
  5. describe,
  6. expect,
  7. it, SpyInstanceFn,
  8. vi,
  9. } from 'vitest';
  10. import card from '../card';
  11. vi.mock('wrap-ansi');
  12. describe('card', () => {
  13. let log: SpyInstanceFn<[], void>;
  14. let defaultConsole: typeof console;
  15. beforeAll(() => {
  16. defaultConsole = console;
  17. log = vi.fn();
  18. global.console = {
  19. log,
  20. } as unknown as typeof console;
  21. });
  22. afterAll(() => {
  23. global.console = defaultConsole;
  24. });
  25. it('calls wrap', async () => {
  26. await card()('foo');
  27. expect(wrapAnsi).toBeCalled();
  28. });
  29. it('calls the console output function', async () => {
  30. await card()('foo');
  31. expect(log).toBeCalled();
  32. });
  33. });