Passed
Push — master ( c712ff...f16bcd )
by Zhenyu
01:27
created

wrapper.js ➔ ???   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
c 1
b 0
f 1
nc 1
dl 0
loc 33
rs 8.8571
nop 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A wrapper.js ➔ ... ➔ ??? 0 6 1
1
import { toMiddlewareWrapper } from '../wrapper';
2
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