diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/client/webconsole/test/node/utils | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/webconsole/test/node/utils')
-rw-r--r-- | devtools/client/webconsole/test/node/utils/areMessagesSimilar.test.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/devtools/client/webconsole/test/node/utils/areMessagesSimilar.test.js b/devtools/client/webconsole/test/node/utils/areMessagesSimilar.test.js new file mode 100644 index 0000000000..23d3bae986 --- /dev/null +++ b/devtools/client/webconsole/test/node/utils/areMessagesSimilar.test.js @@ -0,0 +1,50 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +const { + areMessagesSimilar, +} = require("resource://devtools/client/webconsole/utils/messages.js"); +const { + stubPreparedMessages, +} = require("resource://devtools/client/webconsole/test/node/fixtures/stubs/index.js"); + +const expect = require("expect"); + +describe("areMessagesSimilar:", () => { + it("returns true for duplicated messages", () => { + const baseMessage = stubPreparedMessages.get( + "console.log('foobar', 'test')" + ); + + // Repeat ID must be the same even if the timestamp is different. + const message1 = Object.assign({}, baseMessage, { timeStamp: 1 }); + const message2 = Object.assign({}, baseMessage, { timeStamp: 2 }); + + expect(areMessagesSimilar(message1, message2)).toEqual(true); + }); + + it("returns false for different messages", () => { + const message1 = stubPreparedMessages.get("console.log('foobar', 'test')"); + const message2 = Object.assign({}, message1, { + parameters: ["funny", "monkey"], + }); + expect(areMessagesSimilar(message1, message2)).toEqual(false); + }); + + it("returns false for messages with different severities", () => { + const message1 = stubPreparedMessages.get("console.log('foobar', 'test')"); + const message2 = Object.assign({}, message1, { level: "error" }); + expect(areMessagesSimilar(message1, message2)).toEqual(false); + }); + + it("return false for messages with different falsy values", () => { + const messageNaN = stubPreparedMessages.get("console.log(NaN)"); + const messageUnd = stubPreparedMessages.get("console.log(undefined)"); + const messageNul = stubPreparedMessages.get("console.log(null)"); + + expect(areMessagesSimilar(messageNaN, messageUnd)).toEqual(false); + expect(areMessagesSimilar(messageUnd, messageNul)).toEqual(false); + expect(areMessagesSimilar(messageNul, messageNaN)).toEqual(false); + }); +}); |