transforms.spec.ts 715 B

123456789101112131415161718192021
  1. import { flow } from '../../src/transforms/index.js';
  2. import { seedBlock } from '../../src/util.js';
  3. import { Block } from '../../src/primitives.js';
  4. const t0 = (b: Block): Block => ({ ...b, description: b.description + ' t0' });
  5. const t1 = (b: Block): Block => ({ ...b, description: b.description + ' t1' });
  6. test('multiple', () => {
  7. const block = seedBlock({ description: 'test' });
  8. expect(flow(t0, t1)(block).description).toBe('test t0 t1');
  9. });
  10. test('one', () => {
  11. const block = seedBlock({ description: 'test' });
  12. expect(flow(t0)(block).description).toBe('test t0');
  13. });
  14. test('none', () => {
  15. const block = seedBlock({ description: 'test' });
  16. expect(flow()(block).description).toBe('test');
  17. });