Bug 1436110 - Add pageError and evaluationResult tests for thrown strings; r=bgrins.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Tue, 06 Feb 2018 19:18:30 +0100
changeset 403576 9ce4a74db79390abaa052f4537b6721cdaa3beaf
parent 403575 719f138bc9d8ccd986f5a28ccb55d11e2366bbb2
child 403577 3478356d49534d5251842d9f934e7312f3631ab3
push id59525
push usernchevobbe@mozilla.com
push dateTue, 13 Feb 2018 09:59:52 +0000
treeherderautoland@9ce4a74db793 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1436110
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1436110 - Add pageError and evaluationResult tests for thrown strings; r=bgrins. MozReview-Commit-ID: E1HVY5fPwzV
devtools/client/webconsole/new-console-output/test/components/evaluation-result.test.js
devtools/client/webconsole/new-console-output/test/components/page-error.test.js
--- a/devtools/client/webconsole/new-console-output/test/components/evaluation-result.test.js
+++ b/devtools/client/webconsole/new-console-output/test/components/evaluation-result.test.js
@@ -44,16 +44,32 @@ describe("EvaluationResult component:", 
     const message = stubPreparedMessages.get("longString message Error");
     const wrapper = render(EvaluationResult({ message, serviceContainer }));
 
     const text = wrapper.find(".message-body").text();
     expect(text.startsWith("Error: Long error Long error")).toBe(true);
     expect(wrapper.find(".message.error").length).toBe(1);
   });
 
+  it("renders thrown empty string", () => {
+    const message = stubPreparedMessages.get(`eval throw ""`);
+    const wrapper = render(EvaluationResult({ message, serviceContainer }));
+    const text = wrapper.find(".message-body").text();
+    expect(text).toBe("Error");
+    expect(wrapper.find(".message.error").length).toBe(1);
+  });
+
+  it("renders thrown string", () => {
+    const message = stubPreparedMessages.get(`eval throw "tomato"`);
+    const wrapper = render(EvaluationResult({ message, serviceContainer }));
+    const text = wrapper.find(".message-body").text();
+    expect(text).toBe("Error: tomato");
+    expect(wrapper.find(".message.error").length).toBe(1);
+  });
+
   it("renders an inspect command result", () => {
     const message = stubPreparedMessages.get("inspect({a: 1})");
     const wrapper = render(EvaluationResult({ message, serviceContainer }));
 
     expect(wrapper.find(".message-body").text()).toBe("Object { a: 1 }");
   });
 
   it("renders an jsterm command error result", () => {
--- a/devtools/client/webconsole/new-console-output/test/components/page-error.test.js
+++ b/devtools/client/webconsole/new-console-output/test/components/page-error.test.js
@@ -64,16 +64,30 @@ describe("PageError component:", () => {
   it("renders an error with a longString exception message", () => {
     const message = stubPreparedMessages.get("TypeError longString message");
     const wrapper = render(PageError({ message, serviceContainer }));
 
     const text = wrapper.find(".message-body").text();
     expect(text.startsWith("Error: Long error Long error")).toBe(true);
   });
 
+  it("renders thrown empty string", () => {
+    const message = stubPreparedMessages.get(`throw ""`);
+    const wrapper = render(PageError({ message, serviceContainer }));
+    const text = wrapper.find(".message-body").text();
+    expect(text).toBe("uncaught exception: ");
+  });
+
+  it("renders thrown string", () => {
+    const message = stubPreparedMessages.get(`throw "tomato"`);
+    const wrapper = render(PageError({ message, serviceContainer }));
+    const text = wrapper.find(".message-body").text();
+    expect(text).toBe(`uncaught exception: tomato`);
+  });
+
   it("displays a [Learn more] link", () => {
     const store = setupStore();
 
     const message = stubPreparedMessages.get("ReferenceError: asdf is not defined");
 
     serviceContainer.openLink = sinon.spy();
     const wrapper = mount(Provider({store},
       PageError({