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.

56 lines
1.2 KiB

  1. import chalk from 'chalk';
  2. import * as obliqueStrategiesCore from '@theoryofnekomata/oblique-strategies-core';
  3. import {
  4. describe,
  5. it,
  6. expect,
  7. vi, beforeAll, afterAll, beforeEach, afterEach,
  8. } from 'vitest';
  9. import { main } from '../app';
  10. import * as presenters from '../presenters';
  11. vi.mock('@theoryofnekomata/oblique-strategies-core');
  12. vi.mock('chalk');
  13. vi.mock('wrap-ansi');
  14. vi.mock('../readers/file');
  15. vi.mock('../readers/http');
  16. vi.mock('../readers/https');
  17. vi.mock('../readers/text');
  18. vi.mock('../presenters');
  19. describe('formatting', () => {
  20. let defaultConsole: typeof console;
  21. beforeAll(() => {
  22. defaultConsole = console;
  23. global.console = {
  24. log: () => {
  25. // noop
  26. },
  27. } as unknown as typeof console;
  28. });
  29. afterAll(() => {
  30. global.console = defaultConsole;
  31. });
  32. beforeAll(() => {
  33. vi.mocked(presenters.plain).mockReturnValue(vi.fn());
  34. });
  35. afterAll(() => {
  36. vi.mocked(presenters.plain).mockReset();
  37. });
  38. it('formats the card when italic parts are found', async () => {
  39. vi.mocked(obliqueStrategiesCore.generate).mockReturnValueOnce('foo\n-italic');
  40. await main({
  41. presentation: 'plain',
  42. formatted: true,
  43. cards: ['default'],
  44. });
  45. expect(chalk.italic).toBeCalled();
  46. });
  47. });