Passed
Push — master ( 9157a5...293fbd )
by Zhenyu
01:50
created

src/__tests__/setup.js   A

Complexity

Total Complexity 7
Complexity/F 1

Size

Lines of Code 43
Function Count 7

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 0
wmc 7
eloc 26
c 1
b 0
f 1
nc 1
mnd 0
bc 7
fnc 7
dl 0
loc 43
rs 10
bpm 1
cpm 1
noi 4

1 Function

Rating   Name   Duplication   Size   Complexity  
A setup.js ➔ ??? 0 35 1
1
import * as nAutoMetrics from '@financial-times/n-auto-metrics';
2
import * as nAutoLogger from '@financial-times/n-auto-logger';
3
4
import setupMonitor from '../setup';
5
6
jest.mock('@financial-times/n-auto-metrics');
0 ignored issues
show
Bug introduced by
The variable jest seems to be never declared. If this is a global, consider adding a /** global: jest */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
7
jest.mock('@financial-times/n-auto-logger');
8
9
describe('setupMonitor', () => {
10
	afterEach(() => {
11
		jest.resetAllMocks();
0 ignored issues
show
Bug introduced by
The variable jest seems to be never declared. If this is a global, consider adding a /** global: jest */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
12
	});
13
14
	afterAll(() => {
15
		jest.resetModules();
0 ignored issues
show
Bug introduced by
The variable jest seems to be never declared. If this is a global, consider adding a /** global: jest */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
16
	});
17
18
	const app = {
19
		use: jest.fn(),
0 ignored issues
show
Bug introduced by
The variable jest seems to be never declared. If this is a global, consider adding a /** global: jest */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
20
	};
21
	const metrics = {};
22
	const logger = {};
23
24
	it('initAutoMetrics if metrics instance is provided', () => {
25
		setupMonitor({ app, metrics });
26
		expect(nAutoMetrics.initAutoMetrics).toBeCalledWith(metrics);
27
	});
28
29
	it('setupLoggerInstance to override the default if logger is provided', () => {
30
		setupMonitor({ app, logger });
31
		expect(nAutoLogger.setupLoggerInstance).toBeCalledWith(logger);
32
	});
33
34
	it('do include enhancedRender middleware with autoNext default to true', () => {
35
		setupMonitor({ app });
36
		expect(app.use.mock.calls).toMatchSnapshot();
37
	});
38
39
	it('do not include enhancedRender middleware is autoNext disabled', () => {
40
		setupMonitor({ app, autoNext: false });
41
		expect(app.use.mock.calls).toMatchSnapshot();
42
	});
43
});
44