From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001
From: Daniel Baumann <daniel.baumann@progress-linux.org>
Date: Sun, 7 Apr 2024 19:32:43 +0200
Subject: Adding upstream version 1:115.7.0.

Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
---
 .../components/CollapsibleSection.test.jsx         | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 browser/components/newtab/test/unit/content-src/components/CollapsibleSection.test.jsx

(limited to 'browser/components/newtab/test/unit/content-src/components/CollapsibleSection.test.jsx')

diff --git a/browser/components/newtab/test/unit/content-src/components/CollapsibleSection.test.jsx b/browser/components/newtab/test/unit/content-src/components/CollapsibleSection.test.jsx
new file mode 100644
index 0000000000..f2a8e276b4
--- /dev/null
+++ b/browser/components/newtab/test/unit/content-src/components/CollapsibleSection.test.jsx
@@ -0,0 +1,67 @@
+import { _CollapsibleSection as CollapsibleSection } from "content-src/components/CollapsibleSection/CollapsibleSection";
+import { ErrorBoundary } from "content-src/components/ErrorBoundary/ErrorBoundary";
+import { mount } from "enzyme";
+import React from "react";
+
+const DEFAULT_PROPS = {
+  id: "cool",
+  className: "cool-section",
+  title: "Cool Section",
+  prefName: "collapseSection",
+  collapsed: false,
+  eventSource: "foo",
+  document: {
+    addEventListener: () => {},
+    removeEventListener: () => {},
+    visibilityState: "visible",
+  },
+  dispatch: () => {},
+  Prefs: { values: { featureConfig: {} } },
+};
+
+describe("CollapsibleSection", () => {
+  let wrapper;
+
+  function setup(props = {}) {
+    const customProps = Object.assign({}, DEFAULT_PROPS, props);
+    wrapper = mount(
+      <CollapsibleSection {...customProps}>foo</CollapsibleSection>
+    );
+  }
+
+  beforeEach(() => setup());
+
+  it("should render the component", () => {
+    assert.ok(wrapper.exists());
+  });
+
+  it("should render an ErrorBoundary with class section-body-fallback", () => {
+    assert.equal(
+      wrapper.find(ErrorBoundary).first().prop("className"),
+      "section-body-fallback"
+    );
+  });
+
+  describe("without collapsible pref", () => {
+    let dispatch;
+    beforeEach(() => {
+      dispatch = sinon.stub();
+      setup({ collapsed: undefined, dispatch });
+    });
+    it("should render the section uncollapsed", () => {
+      assert.isFalse(
+        wrapper.find(".collapsible-section").first().hasClass("collapsed")
+      );
+    });
+
+    it("should not render the arrow if no collapsible pref exists for the section", () => {
+      assert.lengthOf(wrapper.find(".click-target .collapsible-arrow"), 0);
+    });
+  });
+
+  describe("icon", () => {
+    it("no icon should be shown", () => {
+      assert.lengthOf(wrapper.find(".icon"), 0);
+    });
+  });
+});
-- 
cgit v1.2.3

