summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/node/components/console-output.test.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/webconsole/test/node/components/console-output.test.js
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/webconsole/test/node/components/console-output.test.js')
-rw-r--r--devtools/client/webconsole/test/node/components/console-output.test.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/devtools/client/webconsole/test/node/components/console-output.test.js b/devtools/client/webconsole/test/node/components/console-output.test.js
new file mode 100644
index 0000000000..a12c2fbae2
--- /dev/null
+++ b/devtools/client/webconsole/test/node/components/console-output.test.js
@@ -0,0 +1,52 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
+const {
+ createFactory,
+} = require("resource://devtools/client/shared/vendor/react.js");
+// Test utils.
+const expect = require("expect");
+const { render } = require("enzyme");
+const Provider = createFactory(
+ require("resource://devtools/client/shared/vendor/react-redux.js").Provider
+);
+
+const ConsoleOutput = createFactory(
+ require("resource://devtools/client/webconsole/components/Output/ConsoleOutput.js")
+);
+const serviceContainer = require("resource://devtools/client/webconsole/test/node/fixtures/serviceContainer.js");
+const {
+ setupStore,
+} = require("resource://devtools/client/webconsole/test/node/helpers.js");
+
+const MESSAGES_NUMBER = 100;
+function getDefaultProps() {
+ const store = setupStore(
+ Array.from({ length: MESSAGES_NUMBER })
+ // Alternate message so we don't trigger the repeat mechanism.
+ .map((_, i) => (i % 2 ? "console.log(null)" : "console.log(NaN)"))
+ );
+
+ return {
+ store,
+ serviceContainer,
+ };
+}
+
+describe("ConsoleOutput component:", () => {
+ it("Render every message", () => {
+ const Services = require("resource://devtools/client/shared/test-helpers/jest-fixtures/Services.js");
+ Services.prefs.setBoolPref("devtools.testing", true);
+
+ // We need to wrap the ConsoleApiElement in a Provider in order for the
+ // ObjectInspector to work.
+ const rendered = render(
+ Provider({ store: setupStore() }, ConsoleOutput(getDefaultProps()))
+ );
+
+ Services.prefs.setBoolPref("devtools.testing", false);
+ const visibleMessages = JSON.parse(rendered.prop("data-visible-messages"));
+ expect(visibleMessages.length).toBe(MESSAGES_NUMBER);
+ });
+});