blob: 7f44ba45e32351cdb2a481de5495c7ab45845bfc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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");
}
});
|