small fix to make the alert test more readable (#85)

This commit is contained in:
Erik Jan de Wit 2020-09-11 20:34:43 +02:00 committed by GitHub
parent 1297c9f391
commit 55a0f443ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 70 deletions

View file

@ -18,10 +18,12 @@ const WithButton = () => {
);
};
it("renders global alerts", () => {
it("renders empty alert panel", () => {
const empty = mount(<AlertPanel alerts={[]} onCloseAlert={() => {}} />);
expect(empty).toMatchSnapshot();
});
it("remove alert after timeout", () => {
const tree = mount(<WithButton />);
const button = tree.find("button");
expect(button).not.toBeNull();
@ -29,10 +31,10 @@ it("renders global alerts", () => {
act(() => {
button!.simulate("click");
});
expect(tree).toMatchSnapshot();
expect(tree).toMatchSnapshot("with alert");
act(() => {
jest.runAllTimers();
});
expect(tree).toMatchSnapshot();
expect(tree).toMatchSnapshot("cleared alert");
});

View file

@ -1,6 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders global alerts 1`] = `
exports[`remove alert after timeout: cleared alert 1`] = `
<WithButton>
<AlertPanel
alerts={Array []}
onCloseAlert={[Function]}
@ -27,9 +28,27 @@ exports[`renders global alerts 1`] = `
</Portal>
</AlertGroup>
</AlertPanel>
<Button
onClick={[Function]}
>
<button
aria-disabled={false}
aria-label={null}
className="pf-c-button pf-m-primary"
data-ouia-component-id={0}
data-ouia-component-type="PF4/Button"
data-ouia-safe={true}
disabled={false}
onClick={[Function]}
type="button"
>
Add
</button>
</Button>
</WithButton>
`;
exports[`renders global alerts 2`] = `
exports[`remove alert after timeout: with alert 1`] = `
<WithButton>
<AlertPanel
alerts={Array []}
@ -146,8 +165,7 @@ exports[`renders global alerts 2`] = `
</WithButton>
`;
exports[`renders global alerts 3`] = `
<WithButton>
exports[`renders empty alert panel 1`] = `
<AlertPanel
alerts={Array []}
onCloseAlert={[Function]}
@ -174,22 +192,4 @@ exports[`renders global alerts 3`] = `
</Portal>
</AlertGroup>
</AlertPanel>
<Button
onClick={[Function]}
>
<button
aria-disabled={false}
aria-label={null}
className="pf-c-button pf-m-primary"
data-ouia-component-id={0}
data-ouia-component-type="PF4/Button"
data-ouia-safe={true}
disabled={false}
onClick={[Function]}
type="button"
>
Add
</button>
</Button>
</WithButton>
`;