Skip to content

Commit

Permalink
test(core): isDismissed tests for getUnreadIpexGrantNotifications
Browse files Browse the repository at this point in the history
  • Loading branch information
iFergal committed Apr 30, 2024
1 parent b0cbb27 commit 716e1f3
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/core/agent/services/credentialService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
} from "../records/credentialMetadataRecord.types";
import { CredentialMetadataRecord } from "../records/credentialMetadataRecord";
import { EventService } from "./eventService";
import { RecordType } from "../../storage/storage.types";
import { NotificationRoute } from "../agent.types";

const basicStorage = jest.mocked({
open: jest.fn(),
Expand Down Expand Up @@ -396,4 +398,42 @@ describe("Credential service of agent", () => {
credentialService.getCredentialDetailsById(id)
).rejects.toThrowError(CredentialService.CREDENTIAL_NOT_FOUND);
});

test("Should be able to getUnreadIpexGrantNotifications", async () => {
const basicRecord = {
_tags: {
isDismiss: true,
type: RecordType.KERIA_NOTIFICATION,
route: NotificationRoute.Credential,
},
id: "AIeGgKkS23FDK4mxpfodpbWhTydFz2tdM64DER6EdgG-",
createdAt: new Date(),
content: {
r: NotificationRoute.Credential,
d: "EF6Nmxz8hs0oVc4loyh2J5Sq9H3Z7apQVqjO6e4chtsp",
},
};
basicStorage.findAllByQuery = jest.fn().mockResolvedValue([basicRecord]);
expect(
await credentialService.getUnreadIpexGrantNotifications()
).toStrictEqual([
{
id: basicRecord.id,
createdAt: basicRecord.createdAt,
a: basicRecord.content,
},
]);
});

test("Should pass the filter throught findAllByQuery when call getUnreadIpexGrantNotifications", async () => {
basicStorage.findAllByQuery = jest.fn().mockResolvedValue([]);
await credentialService.getUnreadIpexGrantNotifications({
isDismissed: false,
});
expect(basicStorage.findAllByQuery).toBeCalledWith({
type: RecordType.KERIA_NOTIFICATION,
route: NotificationRoute.Credential,
isDismissed: false,
});
});
});

0 comments on commit 716e1f3

Please sign in to comment.