forked from jagregory/cognito-local
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
410 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { ClockFake } from "../../src/__tests__/clockFake"; | ||
import { UUID } from "../../src/__tests__/patterns"; | ||
import { withCognitoSdk } from "./setup"; | ||
|
||
const currentDate = new Date(); | ||
const roundedDate = new Date(currentDate.getTime()); | ||
roundedDate.setMilliseconds(0); | ||
|
||
const clock = new ClockFake(currentDate); | ||
|
||
describe( | ||
"CognitoIdentityServiceProvider.createGroup", | ||
withCognitoSdk( | ||
(Cognito) => { | ||
it("creates a group with only the required parameters", async () => { | ||
const client = Cognito(); | ||
|
||
const createGroupResult = await client | ||
.createGroup({ | ||
GroupName: "abc", | ||
UserPoolId: "test", | ||
}) | ||
.promise(); | ||
|
||
expect(createGroupResult).toEqual({ | ||
Group: { | ||
CreationDate: roundedDate, | ||
GroupName: "abc", | ||
LastModifiedDate: roundedDate, | ||
UserPoolId: "test", | ||
}, | ||
}); | ||
}); | ||
|
||
it("creates a group with all parameters", async () => { | ||
const client = Cognito(); | ||
|
||
const createGroupResult = await client | ||
.createGroup({ | ||
Description: "Description", | ||
GroupName: "abc", | ||
Precedence: 1, | ||
RoleArn: "arn", | ||
UserPoolId: "test", | ||
}) | ||
.promise(); | ||
|
||
expect(createGroupResult).toEqual({ | ||
Group: { | ||
CreationDate: roundedDate, | ||
Description: "Description", | ||
GroupName: "abc", | ||
LastModifiedDate: roundedDate, | ||
Precedence: 1, | ||
RoleArn: "arn", | ||
UserPoolId: "test", | ||
}, | ||
}); | ||
}); | ||
}, | ||
{ | ||
clock, | ||
} | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { UserPoolClient } from "../services"; | ||
|
||
export const MockUserPoolClient = { | ||
config: { | ||
Id: "test", | ||
} as Record<string, string>, | ||
createAppClient: jest.fn() as jest.MockedFunction< | ||
UserPoolClient["createAppClient"] | ||
>, | ||
getUserByUsername: jest.fn() as jest.MockedFunction< | ||
UserPoolClient["getUserByUsername"] | ||
>, | ||
listUsers: jest.fn() as jest.MockedFunction<UserPoolClient["listUsers"]>, | ||
saveUser: jest.fn() as jest.MockedFunction<UserPoolClient["saveUser"]>, | ||
listGroups: jest.fn() as jest.MockedFunction<UserPoolClient["listGroups"]>, | ||
saveGroup: jest.fn() as jest.MockedFunction<UserPoolClient["saveGroup"]>, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.