| Conditions | 1 |
| Paths | 1 |
| Total Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | import { toMiddlewareWrapper } from '../wrapper'; |
||
| 3 | describe('toMiddlewareWrapper', () => { |
||
| 4 | it('enhance input function with toMiddleware', () => { |
||
| 5 | const operationFunction = () => {}; |
||
| 6 | const enhanced = toMiddlewareWrapper(operationFunction); |
||
| 7 | expect(typeof enhanced).toBe('function'); |
||
| 8 | expect(enhanced.name).toBe('operationFunction'); |
||
| 9 | }); |
||
| 10 | |||
| 11 | it('enhance input function bundle with toMiddlewares', () => { |
||
| 12 | const createOperationFunction = () => () => {}; |
||
| 13 | const bundle = { |
||
| 14 | methodA: createOperationFunction(), |
||
| 15 | methodB: createOperationFunction(), |
||
| 16 | }; |
||
| 17 | const enhanced = toMiddlewareWrapper(bundle); |
||
| 18 | expect(typeof enhanced).toBe('object'); |
||
| 19 | expect(typeof enhanced.methodA).toBe('function'); |
||
| 20 | expect(enhanced.methodA.name).toBe('methodA'); |
||
| 21 | expect(typeof enhanced.methodB).toBe('function'); |
||
| 22 | expect(enhanced.methodB.name).toBe('methodB'); |
||
| 23 | }); |
||
| 24 | |||
| 25 | it('throws error if given invalid input', () => { |
||
| 26 | const inputString = () => toMiddlewareWrapper('test'); |
||
| 27 | expect(inputString).toThrowErrorMatchingSnapshot(); |
||
| 28 | |||
| 29 | const inputInvalidObject = () => |
||
| 30 | toMiddlewareWrapper({ |
||
| 31 | foo: 'bar', |
||
| 32 | }); |
||
| 33 | expect(inputInvalidObject).toThrowErrorMatchingSnapshot(); |
||
| 34 | }); |
||
| 35 | }); |
||
| 36 |