aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/components/AuthorizationSplash.test.tsx
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-07-10 02:06:42 +0100
committerGravatar GitHub <[email protected]>2024-07-10 02:06:42 +0100
commitd96ea398a414595c907fde7c83027b6b1d42a0e3 (patch)
tree48b287c399570a26bad5fc4ba566bcf2e1cb8356 /src/tests/components/AuthorizationSplash.test.tsx
parentMerge pull request #635 from python-discord/jb3/deps/dep-bumps (diff)
parentAdd new test suite for testing authorization splash (diff)
Merge pull request #634 from python-discord/jb3/auth/popup-and-improvements
Authorization pop-up & misc improvements
Diffstat (limited to 'src/tests/components/AuthorizationSplash.test.tsx')
-rw-r--r--src/tests/components/AuthorizationSplash.test.tsx62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/tests/components/AuthorizationSplash.test.tsx b/src/tests/components/AuthorizationSplash.test.tsx
new file mode 100644
index 0000000..7f44ba4
--- /dev/null
+++ b/src/tests/components/AuthorizationSplash.test.tsx
@@ -0,0 +1,62 @@
+/** @jsx jsx */
+import { jsx } from "@emotion/react";
+import { renderWithProviders } from "../utils";
+import AuthorizationSplash from "../../components/AuthorizationSplash";
+import { finishAuthorizing } from "../../slices/authorization";
+import { act } from "@testing-library/react";
+
+test("authorization splash is hidden when not authorizing", () => {
+ const { container } = renderWithProviders(<AuthorizationSplash />);
+ const splash = container.firstElementChild;
+
+ expect(splash).not.toBe(null);
+
+ if (splash) {
+ const style = window.getComputedStyle(splash);
+ expect(style.opacity).toBe("0");
+ }
+});
+
+test("authorization splash is visible when authorizing state is set", () => {
+ const { container } = renderWithProviders(<AuthorizationSplash />, {
+ preloadedState: {
+ authorization: {
+ authorizing: true
+ }
+ }
+ });
+ const splash = container.firstElementChild;
+
+ expect(splash).not.toBe(null);
+
+ if (splash) {
+ const style = window.getComputedStyle(splash);
+ expect(style.opacity).toBe("1");
+ }
+});
+
+test("test state transitions when authorization completes", () => {
+ const { store, container } = renderWithProviders(<AuthorizationSplash />, {
+ preloadedState: {
+ authorization: {
+ authorizing: true
+ }
+ }
+ });
+
+ const splash = container.firstElementChild;
+
+ expect(splash).not.toBe(null);
+
+ if (splash) {
+ let style = window.getComputedStyle(splash);
+ expect(style.opacity).toBe("1");
+
+ act(() => {
+ store.dispatch(finishAuthorizing());
+ });
+
+ style = window.getComputedStyle(splash);
+ expect(style.opacity).toBe("0");
+ }
+});