Skip to content

Commit

Permalink
fix unit test ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotatek-TungNguyen2a committed Dec 18, 2024
1 parent 8beeab7 commit 0dc5f69
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ArchivedCredentialsContainer } from "./ArchivedCredentials";

const deleteCredentialsMock = jest.fn((id: string) => Promise.resolve(true));
const deleteNotificationMock = jest.fn(() => Promise.resolve(true));
const markCredentialPendingDeleteMock = jest.fn((id: string) => Promise.resolve(true));

jest.mock("../../../core/agent/agent", () => ({
Agent: {
Expand All @@ -24,6 +25,7 @@ jest.mock("../../../core/agent/agent", () => ({
deleteCredential: (id: string) => deleteCredentialsMock(id),
getCredentials: jest.fn().mockResolvedValue([]),
archiveCredential: jest.fn(),
markCredentialPendingDelete: (id: string) => markCredentialPendingDeleteMock(id),
},
keriaNotifications: {
deleteNotificationRecordById: () => deleteNotificationMock(),
Expand Down Expand Up @@ -254,7 +256,7 @@ describe("Archived and revoked credentials", () => {
await passcodeFiller(getByText, getByTestId, "1", 6);

await waitFor(() => {
expect(deleteCredentialsMock).toBeCalled();
expect(markCredentialPendingDeleteMock).toBeCalled();
});
});
});
Expand Down Expand Up @@ -351,7 +353,7 @@ describe("Archived and revoked credentials", () => {
await passcodeFiller(getByText, getByTestId, "1", 6);

await waitFor(() => {
expect(deleteCredentialsMock).toBeCalled();
expect(markCredentialPendingDeleteMock).toBeCalled();
expect(deleteNotificationMock).toBeCalled();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const path = TabsRoutePath.CREDENTIALS + "/" + credsFixAcdc[0].id;
const archiveCredential = jest.fn();
const deleteCredential = jest.fn();
const deleteNotificationRecordById = jest.fn();

const markCredentialPendingDelete = jest.fn();
jest.mock("../../../core/agent/agent", () => ({
Agent: {
agent: {
Expand All @@ -34,6 +34,7 @@ jest.mock("../../../core/agent/agent", () => ({
getCredentials: jest.fn(() => Promise.resolve(true)),
archiveCredential: () => archiveCredential(),
deleteCredential: () => deleteCredential(),
markCredentialPendingDelete:() => markCredentialPendingDelete(),
},
connections: {
getConnectionShortDetailById: jest.fn(() => Promise.resolve([])),
Expand Down Expand Up @@ -657,7 +658,7 @@ describe("Cred Detail Module - archived", () => {
passcodeFiller(getByText, getByTestId, "1", 6);

await waitFor(() => {
expect(deleteCredential).toBeCalled();
expect(markCredentialPendingDelete).toBeCalled();
});

fireEvent.click(getByTestId("alert-delete-archive-cancel-button"));
Expand Down Expand Up @@ -864,7 +865,7 @@ describe("Cred detail - revoked", () => {

await waitFor(() => {
expect(archiveCredential).toBeCalled();
expect(deleteCredential).toBeCalled();
expect(markCredentialPendingDelete).toBeCalled();
expect(deleteNotificationRecordById).toBeCalled();
});
});
Expand Down
7 changes: 4 additions & 3 deletions src/ui/pages/Credentials/Credentials.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ import { CredentialsFilters } from "./Credentials.types";

const deleteIdentifierMock = jest.fn();
const archiveIdentifierMock = jest.fn();

const markCredentialPendingDeleteMock = jest.fn();
jest.mock("../../../core/agent/agent", () => ({
Agent: {
agent: {
credentials: {
getCredentialDetailsById: jest.fn(),
deleteCredential: () => deleteIdentifierMock(),
archiveCredential: () => archiveIdentifierMock(),
getCredentials: jest.fn()
getCredentials: jest.fn(),
markCredentialPendingDelete: () => markCredentialPendingDeleteMock()
},
basicStorage: {
findById: jest.fn(),
Expand Down Expand Up @@ -540,7 +541,7 @@ describe("Creds Tab", () => {
await passcodeFiller(getByText, getByTestId, "1", 6);

await waitFor(() => {
expect(deleteIdentifierMock).toBeCalled();
expect(markCredentialPendingDeleteMock).toBeCalled();
expect(archiveIdentifierMock).toBeCalled();
});
});
Expand Down

0 comments on commit 0dc5f69

Please sign in to comment.