forked from adamlaska/circleci-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrum.test.js
More file actions
55 lines (45 loc) · 1.47 KB
/
rum.test.js
File metadata and controls
55 lines (45 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { datadogRum } from '@datadog/browser-rum';
import { init, getDefaultOptions } from './rum';
import {
isUnsupportedBrowser as isUnsupportedBrowserDefault,
isProduction as isProductionOriginal,
} from '../utils';
jest.mock('../utils');
const isUnsupportedBrowser = isUnsupportedBrowserDefault;
const isProduction = isProductionOriginal;
describe('Real User Monitoring', () => {
describe('init', () => {
beforeEach(() => {
jest.resetAllMocks();
});
it('should call datadogRum init', () => {
const spy = jest.spyOn(datadogRum, 'init');
init();
expect(spy).toBeCalledWith(getDefaultOptions());
});
it('should not call datadogRum init when client is not supported', () => {
isUnsupportedBrowser.mockImplementation(() => true);
const spy = jest.spyOn(datadogRum, 'init');
init();
expect(spy).not.toBeCalled();
});
it('should call datadogRum init with dev env in dev', () => {
isProduction.mockImplementation(() => false);
const spy = jest.spyOn(datadogRum, 'init');
init();
expect(spy).toBeCalledWith({
...getDefaultOptions(),
env: 'development',
});
});
it('should call datadogRum init with prod env in prod', () => {
isProduction.mockImplementation(() => true);
const spy = jest.spyOn(datadogRum, 'init');
init();
expect(spy).toBeCalledWith({
...getDefaultOptions(),
env: 'production',
});
});
});
});