Skip to content

Commit

Permalink
feat: linting (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fran McDade authored and Fran McDade committed Nov 6, 2024
1 parent b7aa1a2 commit 6eebd53
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions tests/terraProfileProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const { TerraProfileProvider } = await import(
"../src/providers/authentication/terra/provider"
);

const MOCK_AUTHENTICATION_DISPATCH = jest.fn();
const MOCK_CREDENTIALS_DISPATCH = jest.fn();
const MOCK_USE_AUTHENTICATION = useAuthentication as jest.MockedFunction<
typeof useAuthentication
>;
Expand All @@ -66,17 +68,14 @@ const MOCK_USE_FETCH_PROFILES = useFetchProfiles as jest.MockedFunction<
>;

describe("TerraProfileProvider", () => {
const mockAuthenticationDispatch = jest.fn();
const mockCredentialsDispatch = jest.fn();

beforeEach(() => {
jest.clearAllMocks();
MOCK_USE_AUTHENTICATION.mockReturnValue({
authenticationDispatch: mockAuthenticationDispatch,
authenticationDispatch: MOCK_AUTHENTICATION_DISPATCH,
authenticationState: DEFAULT_AUTHENTICATION_STATE,
});
MOCK_USE_CREDENTIALS.mockReturnValue({
credentialsDispatch: mockCredentialsDispatch,
credentialsDispatch: MOCK_CREDENTIALS_DISPATCH,
credentialsState: DEFAULT_CREDENTIALS_STATE,
});
MOCK_USE_FETCH_PROFILES.mockReturnValue(PROFILE_PENDING);
Expand All @@ -88,8 +87,8 @@ describe("TerraProfileProvider", () => {
<div>Child Component</div>
</TerraProfileProvider>
);
expect(mockAuthenticationDispatch).not.toHaveBeenCalled();
expect(mockCredentialsDispatch).not.toHaveBeenCalled();
expect(MOCK_AUTHENTICATION_DISPATCH).not.toHaveBeenCalled();
expect(MOCK_CREDENTIALS_DISPATCH).not.toHaveBeenCalled();
});

it("calls authenticationComplete dispatch when terra profile is SETTLED and INACTIVE", () => {
Expand All @@ -99,10 +98,10 @@ describe("TerraProfileProvider", () => {
<div>Child Component</div>
</TerraProfileProvider>
);
expect(mockAuthenticationDispatch).toHaveBeenCalledWith(
expect(MOCK_AUTHENTICATION_DISPATCH).toHaveBeenCalledWith(
authenticationComplete()
);
expect(mockCredentialsDispatch).not.toHaveBeenCalled();
expect(MOCK_CREDENTIALS_DISPATCH).not.toHaveBeenCalled();
});

it("dispatches authenticationComplete and updateCredentials when terra profile is SETTLED and ACTIVE", () => {
Expand All @@ -112,10 +111,10 @@ describe("TerraProfileProvider", () => {
<div>Child Component</div>
</TerraProfileProvider>
);
expect(mockAuthenticationDispatch).toHaveBeenCalledWith(
expect(MOCK_AUTHENTICATION_DISPATCH).toHaveBeenCalledWith(
authenticationComplete()
);
expect(mockCredentialsDispatch).toHaveBeenCalledWith(
expect(MOCK_CREDENTIALS_DISPATCH).toHaveBeenCalledWith(
updateCredentials(TOKEN)
);
});
Expand Down

0 comments on commit 6eebd53

Please sign in to comment.