-
Notifications
You must be signed in to change notification settings - Fork 45.7k
/
moduleFilters-test.js
79 lines (72 loc) · 2.2 KB
/
moduleFilters-test.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import {isInternalModule} from '../moduleFilters';
describe('isInternalModule', () => {
let map;
function createFlamechartStackFrame(scriptUrl, locationLine, locationColumn) {
return {
name: 'test',
timestamp: 0,
duration: 1,
scriptUrl,
locationLine,
locationColumn,
};
}
function createStackFrame(fileName, lineNumber, columnNumber) {
return {
columnNumber: columnNumber,
lineNumber: lineNumber,
fileName: fileName,
functionName: 'test',
source: ` at test (${fileName}:${lineNumber}:${columnNumber})`,
};
}
beforeEach(() => {
map = new Map();
map.set('foo', [
[createStackFrame('foo', 10, 0), createStackFrame('foo', 15, 100)],
]);
map.set('bar', [
[createStackFrame('bar', 10, 0), createStackFrame('bar', 15, 100)],
[createStackFrame('bar', 20, 0), createStackFrame('bar', 25, 100)],
]);
});
it('should properly identify stack frames within the provided module ranges', () => {
expect(
isInternalModule(map, createFlamechartStackFrame('foo', 10, 0)),
).toBe(true);
expect(
isInternalModule(map, createFlamechartStackFrame('foo', 12, 35)),
).toBe(true);
expect(
isInternalModule(map, createFlamechartStackFrame('foo', 15, 100)),
).toBe(true);
expect(
isInternalModule(map, createFlamechartStackFrame('bar', 12, 0)),
).toBe(true);
expect(
isInternalModule(map, createFlamechartStackFrame('bar', 22, 125)),
).toBe(true);
});
it('should properly identify stack frames outside of the provided module ranges', () => {
expect(isInternalModule(map, createFlamechartStackFrame('foo', 9, 0))).toBe(
false,
);
expect(
isInternalModule(map, createFlamechartStackFrame('foo', 15, 101)),
).toBe(false);
expect(
isInternalModule(map, createFlamechartStackFrame('bar', 17, 0)),
).toBe(false);
expect(
isInternalModule(map, createFlamechartStackFrame('baz', 12, 0)),
).toBe(false);
});
});