From 8637a5d77d2ec7b6e7e1db29b668b5def97c8ca9 Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Thu, 18 May 2023 08:30:55 +0000 Subject: [PATCH] Take Jest snapshots of widgets (`AppTile`) (#10897) * Take a Jest snapshot of a widget (AppTile) * Fix the comment * Update test/components/views/elements/AppTile-test.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Add container --------- Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/elements/AppTile-test.tsx | 7 ++ .../__snapshots__/AppTile-test.tsx.snap | 64 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 test/components/views/elements/__snapshots__/AppTile-test.tsx.snap diff --git a/test/components/views/elements/AppTile-test.tsx b/test/components/views/elements/AppTile-test.tsx index b9eef670e0..4518adede3 100644 --- a/test/components/views/elements/AppTile-test.tsx +++ b/test/components/views/elements/AppTile-test.tsx @@ -359,6 +359,13 @@ describe("AppTile", () => { moveToContainerSpy = jest.spyOn(WidgetLayoutStore.instance, "moveToContainer"); }); + it("should render", () => { + const { container, asFragment } = renderResult; + + expect(container.querySelector(".mx_Spinner")).toBeFalsy(); // Assert that the spinner is gone + expect(asFragment()).toMatchSnapshot(); // Take a snapshot of the pinned widget + }); + it("should not display the »Popout widget« button", () => { expect(renderResult.queryByLabelText("Popout widget")).not.toBeInTheDocument(); }); diff --git a/test/components/views/elements/__snapshots__/AppTile-test.tsx.snap b/test/components/views/elements/__snapshots__/AppTile-test.tsx.snap new file mode 100644 index 0000000000..d0dbe25a79 --- /dev/null +++ b/test/components/views/elements/__snapshots__/AppTile-test.tsx.snap @@ -0,0 +1,64 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AppTile for a pinned widget should render 1`] = ` + +
+
+ + + + + Example 1 + + + + + +
+
+ +
+
+
+
+ +`;