chore(test): rewritten app component test using rtl (#4629)

This commit is contained in:
Tharun Rajendran 2022-03-21 21:55:54 +05:30 committed by GitHub
parent 2edffeebd7
commit 68572dbd36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
import { mount } from "enzyme";
import { render } from "@testing-library/react";
import ConnectedApp from "./App";
import * as authActions from "../../redux/nodes/auth/actions";
@ -10,14 +10,14 @@ const { connectedComponent, reduxMockStore } = helpers;
describe("App - component", () => {
const store = { app: {}, auth: {}, notifications: {} };
const mockStore = reduxMockStore(store);
const component = mount(connectedComponent(ConnectedApp, { mockStore }));
const component = render(connectedComponent(ConnectedApp, { mockStore }));
afterEach(() => {
local.setItem("auth_token", null);
});
it("renders", () => {
expect(component).toBeTruthy();
expect(component).not.toBeNull();
});
it("loads the current user if there is an auth token but no user", () => {
@ -33,7 +33,7 @@ describe("App - component", () => {
});
const application = connectedComponent(ConnectedApp, { mockStore });
mount(application);
render(application);
expect(spy).toHaveBeenCalled();
});
@ -60,7 +60,7 @@ describe("App - component", () => {
mockStore: mockStoreWithUser,
});
mount(application);
render(application);
expect(spy).not.toHaveBeenCalled();
});
@ -74,7 +74,7 @@ describe("App - component", () => {
});
const application = connectedComponent(ConnectedApp, { mockStore });
mount(application);
render(application);
expect(spy).not.toHaveBeenCalled();
});
});