Skip to content

Commit

Permalink
test(api): update test to include group type
Browse files Browse the repository at this point in the history
  • Loading branch information
waddaboo committed Oct 17, 2024
1 parent d21d6e2 commit 90445fc
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 9 deletions.
9 changes: 9 additions & 0 deletions apps/api/src/app/credentials/credentials.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { InvitesService } from "../invites/invites.service"
import { OAuthAccount } from "./entities/credentials-account.entity"
import { CredentialsService } from "./credentials.service"
import { AdminsModule } from "../admins/admins.module"
import { GroupType } from "../groups/types"

jest.mock("@bandada/utils", () => {
const originalModule = jest.requireActual("@bandada/utils")
Expand Down Expand Up @@ -83,6 +84,7 @@ describe("CredentialsService", () => {
{
name: "Group1",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand All @@ -104,6 +106,7 @@ describe("CredentialsService", () => {
{
name: "Group2",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
Expand Down Expand Up @@ -186,6 +189,7 @@ describe("CredentialsService", () => {
{
name: "Group2",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand Down Expand Up @@ -232,6 +236,7 @@ describe("CredentialsService", () => {
{
name: "Group2",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand Down Expand Up @@ -337,6 +342,7 @@ describe("CredentialsService", () => {
{
name: "Group2",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand Down Expand Up @@ -387,6 +393,7 @@ describe("CredentialsService", () => {
{
name: "Group3",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand Down Expand Up @@ -439,6 +446,7 @@ describe("CredentialsService", () => {
{
name: "Group4",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand Down Expand Up @@ -492,6 +500,7 @@ describe("CredentialsService", () => {
{
name: "Group5",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand Down
54 changes: 45 additions & 9 deletions apps/api/src/app/groups/groups.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AdminsModule } from "../admins/admins.module"
import { Admin } from "../admins/entities/admin.entity"
import { CreateGroupDto } from "./dto/create-group.dto"
import { UpdateGroupDto } from "./dto/update-group.dto"
import { GroupType } from "./types"

jest.mock("@bandada/utils", () => {
const originalModule = jest.requireActual("@bandada/utils")
Expand Down Expand Up @@ -66,6 +67,7 @@ describe("GroupsService", () => {
{
name: "Group1",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
Expand All @@ -77,16 +79,19 @@ describe("GroupsService", () => {

describe("# createGroup", () => {
it("Should create a group", async () => {
const { treeDepth, members } = await groupsService.createGroup(
{
name: "Group2",
description: "This is a description",
treeDepth: 16,
fingerprintDuration: 3600
},
"admin"
)
const { type, treeDepth, members } =
await groupsService.createGroup(
{
name: "Group2",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
"admin"
)

expect(type).toBe(GroupType.OFFCHAIN)
expect(treeDepth).toBe(16)
expect(members).toHaveLength(0)
})
Expand All @@ -98,6 +103,7 @@ describe("GroupsService", () => {
{
name: "Group3",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
Expand Down Expand Up @@ -126,6 +132,7 @@ describe("GroupsService", () => {
{
name: "Group4",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600,
credentials: {
Expand Down Expand Up @@ -200,6 +207,7 @@ describe("GroupsService", () => {
{
name: "Group01",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
Expand All @@ -211,6 +219,7 @@ describe("GroupsService", () => {
{
name: "Group02",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
Expand All @@ -229,6 +238,7 @@ describe("GroupsService", () => {
{
name: "MemberGroup",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
Expand Down Expand Up @@ -319,6 +329,7 @@ describe("GroupsService", () => {
{
name: "MemberGroup",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
Expand Down Expand Up @@ -382,6 +393,7 @@ describe("GroupsService", () => {
{
name: "Group2",
description: "This is a new group",
type: GroupType.OFFCHAIN,
treeDepth: 21,
fingerprintDuration: 3600
},
Expand Down Expand Up @@ -426,6 +438,7 @@ describe("GroupsService", () => {
{
name: "Group2",
description: "This is a new group",
type: GroupType.OFFCHAIN,
treeDepth: 21,
fingerprintDuration: 3600
},
Expand Down Expand Up @@ -455,6 +468,7 @@ describe("GroupsService", () => {
const groupDto: CreateGroupDto = {
name: "Group",
description: "This is a new group",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
}
Expand Down Expand Up @@ -611,20 +625,23 @@ describe("GroupsService", () => {
id: "1",
name: "Group1",
description: "This is a new group1",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
{
id: "2",
name: "Group2",
description: "This is a new group2",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
{
id: "3",
name: "Group3",
description: "This is a new group3",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
}
Expand Down Expand Up @@ -785,6 +802,7 @@ describe("GroupsService", () => {
id: "1",
name: "Group1",
description: "This is a new group1",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
}
Expand Down Expand Up @@ -888,13 +906,15 @@ describe("GroupsService", () => {
id: "1",
name: "Group1",
description: "This is a new group1",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
{
id: "2",
name: "Group2",
description: "This is a new group2",
type: GroupType.OFFCHAIN,
treeDepth: 32,
fingerprintDuration: 7200
}
Expand Down Expand Up @@ -1028,6 +1048,7 @@ describe("GroupsService", () => {
{
name: "Group2",
description: "This is a new group",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
Expand Down Expand Up @@ -1178,6 +1199,7 @@ describe("GroupsService", () => {
{
name: "Group2",
description: "This is a new group",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
Expand All @@ -1202,6 +1224,7 @@ describe("GroupsService", () => {
{
name: "Credential Group",
description: "This is a new group",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600,
credentials: {
Expand Down Expand Up @@ -1350,6 +1373,7 @@ describe("GroupsService", () => {
{
name: "Group2",
description: "This is a new group",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
Expand Down Expand Up @@ -1398,6 +1422,7 @@ describe("GroupsService", () => {
{
name: "Group2",
description: "This is a new group",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
Expand Down Expand Up @@ -1425,6 +1450,7 @@ describe("GroupsService", () => {
{
name: "Credential Group",
description: "This is a new group",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600,
credentials: {
Expand Down Expand Up @@ -1476,6 +1502,7 @@ describe("GroupsService", () => {
id: "1",
name: "Group1",
description: "This is a new group1",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
}
Expand Down Expand Up @@ -1518,13 +1545,15 @@ describe("GroupsService", () => {
id: "1",
name: "Group1",
description: "This is a new group1",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
{
id: "2",
name: "Group2",
description: "This is a new group2",
type: GroupType.OFFCHAIN,
treeDepth: 32,
fingerprintDuration: 7200
}
Expand Down Expand Up @@ -1571,6 +1600,7 @@ describe("GroupsService", () => {
id: "1",
name: "Group1",
description: "This is a new group1",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
}
Expand Down Expand Up @@ -1623,13 +1653,15 @@ describe("GroupsService", () => {
id: "1",
name: "Group1",
description: "This is a new group1",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
{
id: "2",
name: "Group2",
description: "This is a new group2",
type: GroupType.OFFCHAIN,
treeDepth: 32,
fingerprintDuration: 7200
}
Expand Down Expand Up @@ -1706,6 +1738,7 @@ describe("GroupsService", () => {
id: "1",
name: "Group1",
description: "This is a new group1",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
}
Expand Down Expand Up @@ -1778,13 +1811,15 @@ describe("GroupsService", () => {
id: "1",
name: "Group1",
description: "This is a new group1",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
{
id: "2",
name: "Group2",
description: "This is a new group2",
type: GroupType.OFFCHAIN,
treeDepth: 32,
fingerprintDuration: 7200
}
Expand Down Expand Up @@ -1879,6 +1914,7 @@ describe("GroupsService", () => {
{
name: "Fingerprint Group",
description: "This is a description",
type: GroupType.OFFCHAIN,
treeDepth: 16,
fingerprintDuration: 3600
},
Expand Down
Loading

0 comments on commit 90445fc

Please sign in to comment.