forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframe.spec.js
More file actions
121 lines (104 loc) · 2.92 KB
/
frame.spec.js
File metadata and controls
121 lines (104 loc) · 2.92 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* eslint max-nested-callbacks: ["error", 6] */
import {
simplifyDisplayName,
formatDisplayName,
formatCopyName,
getLibraryFromUrl
} from "../frame";
const cases = {
defaultCase: [["define", "define"]],
objectProperty: [
["z.foz", "foz"],
["z.foz/baz", "baz"],
["z.foz/baz/y.bay", "bay"],
["outer/x.fox.bax.nx", "nx"],
["outer/fow.baw", "baw"],
["fromYUI._attach", "_attach"],
["Y.ClassNameManager</getClassName", "getClassName"],
["orion.textview.TextView</addHandler", "addHandler"],
["this.eventPool_.createObject", "createObject"]
],
arrayProperty: [
["this.eventPool_[createObject]", "createObject"],
["jQuery.each(^)/jQuery.fn[o]", "o"],
["viewport[get+D]", "get+D"],
["arr[0]", "0"]
],
functionProperty: [
["fromYUI._attach/<.", "_attach"],
["Y.ClassNameManager<", "ClassNameManager"],
["fromExtJS.setVisible/cb<", "cb"],
["fromDojo.registerWin/<", "registerWin"]
],
annonymousProperty: [["jQuery.each(^)", "each"]]
};
describe("function names", () => {
describe("simplifying display names", () => {
Object.keys(cases).forEach(type => {
cases[type].forEach(([kase, expected]) => {
it(`${type} - ${kase}`, () =>
expect(simplifyDisplayName(kase)).toEqual(expected));
});
});
});
describe("formatting display names", () => {
it("uses a library description", () => {
const frame = {
library: "Backbone",
displayName: "extend/child",
source: {
url: "assets/backbone.js"
}
};
expect(formatDisplayName(frame)).toEqual("Create Class");
});
it("shortens an anonymous function", () => {
const frame = {
displayName: "extend/child/bar/baz",
source: {
url: "assets/bar.js"
}
};
expect(formatDisplayName(frame)).toEqual("baz");
});
it("truncates long function names", () => {
const frame = {
displayName: "bazbazbazbazbazbazbazbazbazbazbazbazbaz",
source: {
url: "assets/bar.js"
}
};
expect(formatDisplayName(frame)).toEqual("...zbazbazbazbazbazbazbazbaz");
});
});
describe("formatCopyName", () => {
it("simple", () => {
const frame = {
displayName: "child",
location: {
line: 12
},
source: {
url: "todo-view.js"
}
};
expect(formatCopyName(frame)).toEqual("child (todo-view.js#12)");
});
});
describe("getLibraryFromUrl", () => {
describe("When Preact is on the frame", () => {
it("should return Preact and not React", () => {
const frame = {
displayName: "name",
location: {
line: 12
},
source: {
url: "https://cdnjs.cloudflare.com/ajax/libs/preact/8.2.5/preact.js"
}
};
expect(getLibraryFromUrl(frame)).toEqual("Preact");
});
});
});
});