Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

Commit a1ae484

Browse files
committed
output 1
1 parent b85cd07 commit a1ae484

File tree

2 files changed

+73
-5
lines changed

2 files changed

+73
-5
lines changed

devtools/client/webconsole/new-console-output/test/components/console-api-call.test.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,51 @@ describe("ConsoleAPICall component:", () => {
9898
expect(frameLinks.eq(2).find(".frame-link-filename").text()).toBe(filepath);
9999
});
100100
});
101+
102+
describe("console.log (handling tricky values)", () => {
103+
it("renders escaped values", () => {
104+
const message = stubs.get("console.log('hello \nfrom \rthe \"string world!')");
105+
const wrapper = render(ConsoleApiCall(Object.assign({}, props, { message })));
106+
107+
expect(wrapper.find(".message-body").text())
108+
.toBe("hello \\nfrom \\rthe \"string world!");
109+
});
110+
111+
it("renders unicode values", () => {
112+
const message = stubs.get("console.log('\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165')");
113+
const wrapper = render(ConsoleApiCall(Object.assign({}, props, { message })));
114+
115+
expect(wrapper.find(".message-body").text()).toBe("úṇĩçödê țĕșť");
116+
});
117+
118+
// @TODO fill this in once https://github.com/devtools-html/gecko-dev/issues/277 is fixed.
119+
// const message = stubs.get("console.log(longString)");
120+
it("renders longString values");
121+
122+
it("renders number 0", () => {
123+
const message = stubs.get("console.log(0)");
124+
const wrapper = render(ConsoleApiCall(Object.assign({}, props, { message })));
125+
126+
expect(wrapper.find(".message-body").text()).toBe("0");
127+
});
128+
129+
it("renders string '0'", () => {
130+
const message = stubs.get("console.log('0')");
131+
const wrapper = render(ConsoleApiCall(Object.assign({}, props, { message })));
132+
133+
expect(wrapper.find(".message-body").text()).toBe("0");
134+
});
135+
136+
it("renders a regex", () => {
137+
const message = stubs.get("console.log(/foobar/)");
138+
const wrapper = render(ConsoleApiCall(Object.assign({}, props, { message })));
139+
140+
// Ensure that it is linked to variables view.
141+
expect(wrapper.find(".message-body .objectBox-regexp a.cm-variable").text())
142+
.toBe("/foobar/");
143+
});
144+
145+
// @TODO add a test for Symbols when Bug 1303126 is complete
146+
it("renders a Symbol()");
147+
});
101148
});

devtools/client/webconsole/new-console-output/test/fixtures/stub-generators/stub-snippets.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,47 @@
55

66
var {DebuggerServer} = require("devtools/server/main");
77
var longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a");
8-
var initialString = longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
98

109
// Console API
1110

1211
const consoleApiCommands = [
12+
// Log
1313
"console.log('foobar', 'test')",
1414
"console.log(undefined)",
15-
"console.warn('danger, will robinson!')",
1615
"console.log(NaN)",
1716
"console.log(null)",
1817
"console.log('\u9f2c')",
19-
"console.clear()",
20-
"console.count('bar')",
21-
"console.assert(false, {message: 'foobar'})",
2218
"console.log('hello \\nfrom \\rthe \\\"string world!')",
2319
"console.log('\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165')",
20+
"console.log('')",
21+
"console.log(0)",
22+
"console.log('0')",
23+
"console.log(/foobar/)",
24+
"console.log(Symbol('foo'))",
25+
26+
// Warn
27+
"console.warn('danger, will robinson!')",
28+
29+
// Assert
30+
"console.assert(false, {message: 'foobar'})",
31+
32+
// Clear
33+
"console.clear()",
34+
35+
// Count
36+
"console.count('bar')",
2437
];
2538

2639
let consoleApi = new Map(consoleApiCommands.map(
2740
cmd => [cmd, {keys: [cmd], code: cmd}]));
2841

42+
// console.log a long string. It's handled this way so the key can be shorter.
43+
consoleApi.set("console.log(longString)", {
44+
keys: [`console.log(longString)`],
45+
code: `console.log('${longString}')`
46+
});
47+
48+
// Trace
2949
consoleApi.set("console.trace()", {
3050
keys: ["console.trace()"],
3151
code: `
@@ -39,6 +59,7 @@ function foo() {
3959
foo()
4060
`});
4161

62+
// Time
4263
consoleApi.set("console.time('bar')", {
4364
keys: ["console.time('bar')", "console.timeEnd('bar')"],
4465
code: `

0 commit comments

Comments
 (0)