diff options
author | Moonchild <moonchild@palemoon.org> | 2019-07-20 20:43:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-20 20:43:11 +0000 |
commit | 779ef307af82035d987744bc5d6fc74e9fb6fac7 (patch) | |
tree | f52eaf7c1392997b75b176c82218edba4e856eef /devtools/client/webconsole/new-console-output/test/components/page-error.test.js | |
parent | 9dce66f58910b0d1363be3a8e3b5232d79692516 (diff) | |
parent | 4a0061a3e0976d4001e23d66af04b06af792675f (diff) | |
download | UXP-779ef307af82035d987744bc5d6fc74e9fb6fac7.tar UXP-779ef307af82035d987744bc5d6fc74e9fb6fac7.tar.gz UXP-779ef307af82035d987744bc5d6fc74e9fb6fac7.tar.lz UXP-779ef307af82035d987744bc5d6fc74e9fb6fac7.tar.xz UXP-779ef307af82035d987744bc5d6fc74e9fb6fac7.zip |
Merge pull request #1192 from g4jc/parser_tuneup
Issues #816 / #802 - SpiderMonkey Tuneup
Diffstat (limited to 'devtools/client/webconsole/new-console-output/test/components/page-error.test.js')
-rw-r--r-- | devtools/client/webconsole/new-console-output/test/components/page-error.test.js | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git 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 index 93f3a9ea5..5bc5fe0f0 100644 --- 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 @@ -123,4 +123,118 @@ describe("PageError component:", () => { wrapper = render(PageError({ message, serviceContainer})); expect(wrapper.find(".indent").prop("style").width).toBe(`0`); }); + + it("has empty error notes", () => { + const message = stubPreparedMessages.get("ReferenceError: asdf is not defined"); + let wrapper = render(PageError({ message, serviceContainer })); + + const notes = wrapper.find(".error-note"); + + expect(notes.length).toBe(0); + }); + + it("can show an error note", () => { + const origMessage = stubPreparedMessages.get("ReferenceError: asdf is not defined"); + const message = origMessage.set("notes", [ + { + "messageBody": "test note", + "frame": { + "source": "http://example.com/test.js", + "line": 2, + "column": 6 + } + } + ]); + + let wrapper = render(PageError({ message, serviceContainer })); + + const notes = wrapper.find(".error-note"); + expect(notes.length).toBe(1); + + const note = notes.eq(0); + expect(note.find(".message-body").text()) + .toBe("note: test note"); + + // There should be the location. + const locationLink = note.find(`.message-location`); + expect(locationLink.length).toBe(1); + expect(locationLink.text()).toBe("test.js:2:6"); + }); + + it("can show multiple error notes", () => { + const origMessage = stubPreparedMessages.get("ReferenceError: asdf is not defined"); + const message = origMessage.set("notes", [ + { + "messageBody": "test note 1", + "frame": { + "source": "http://example.com/test1.js", + "line": 2, + "column": 6 + } + }, + { + "messageBody": "test note 2", + "frame": { + "source": "http://example.com/test2.js", + "line": 10, + "column": 18 + } + }, + { + "messageBody": "test note 3", + "frame": { + "source": "http://example.com/test3.js", + "line": 9, + "column": 4 + } + } + ]); + + let wrapper = render(PageError({ message, serviceContainer })); + + const notes = wrapper.find(".error-note"); + expect(notes.length).toBe(3); + + const note1 = notes.eq(0); + expect(note1.find(".message-body").text()) + .toBe("note: test note 1"); + + const locationLink1 = note1.find(`.message-location`); + expect(locationLink1.length).toBe(1); + expect(locationLink1.text()).toBe("test1.js:2:6"); + + const note2 = notes.eq(1); + expect(note2.find(".message-body").text()) + .toBe("note: test note 2"); + + const locationLink2 = note2.find(`.message-location`); + expect(locationLink2.length).toBe(1); + expect(locationLink2.text()).toBe("test2.js:10:18"); + + const note3 = notes.eq(2); + expect(note3.find(".message-body").text()) + .toBe("note: test note 3"); + + const locationLink3 = note3.find(`.message-location`); + expect(locationLink3.length).toBe(1); + expect(locationLink3.text()).toBe("test3.js:9:4"); + }); + + it("displays error notes", () => { + const message = stubPreparedMessages.get("SyntaxError: redeclaration of let a"); + + let wrapper = render(PageError({ message, serviceContainer })); + + const notes = wrapper.find(".error-note"); + expect(notes.length).toBe(1); + + const note = notes.eq(0); + expect(note.find(".message-body").text()) + .toBe("note: Previously declared at line 2, column 6"); + + // There should be the location. + const locationLink = note.find(`.message-location`); + expect(locationLink.length).toBe(1); + expect(locationLink.text()).toBe("test-console-api.html:2:6"); + }); }); |