Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import errorTest from "@microtica/mocha-error-test";
- import { assert, expect } from "chai";
- import * as HTTPStatus from "http-status-codes";
- import { CognitoAction } from "../../actions/cognito";
- const userIdArray: string[] = [];
- describe("Unit", () => {
- it("Cognito Action Sign Up User Success", async () => {
- const username = "testUsername";
- const password = "testPassword";
- await new CognitoAction().singUpUser(username, password);
- });
- it("Cognito Action Sign Up User Fail", async () => {
- const username = "testUsername";
- const password = "testPassword";
- await errorTest(
- assert,
- new CognitoAction().singUpUser(username, password),
- HTTPStatus.BAD_REQUEST,
- "Should not be able to create a user with a used Username"
- );
- });
- it("Cognito Action Confirm Sign Up Success", async () => {
- const username = "testUsername";
- const code = "112233";
- await new CognitoAction().confirmSignUp(username, code);
- });
- it("Cognito Action Login User Success", async () => {
- const username = "testUsername";
- const password = "testPassword";
- const response = await new CognitoAction().loginUser(username, password);
- expect(response.done).to.equal(true);
- });
- it("Cognito Action Login User fail", async () => {
- const failUsername = "testUsernameFail";
- const password = "testPassword";
- await errorTest(
- assert,
- new CognitoAction().loginUser(failUsername, password),
- HTTPStatus.BAD_REQUEST,
- "Should fail to log in with wrong credentials"
- );
- });
- it("Cognito Action Set Password Success", async () => {
- const username = "testUsername";
- const password = "testPassword";
- const sessionToken = "someSessionToken";
- const response = await new CognitoAction().setPassword(username, password, sessionToken);
- expect(response.done).to.equal(true);
- });
- it("Cognito Action Create Multiple Users Success", async () => {
- const usernames = ["testUsername000", "testUsername001", "testUsername002", "testUsername003"];
- const response = await new CognitoAction().createMultipleUsers(usernames);
- usernames.forEach(username => {
- userIdArray.push(response[username].id);
- expect(response).to.haveOwnProperty(username);
- });
- });
- it("Cognito Action Create User Success", async () => {
- const username = "newTestUsername";
- const response = await new CognitoAction().createUser(username);
- expect(response.done).to.equal(true);
- });
- it("Cognito Action Get Multiple Users Success", async () => {
- const response = await new CognitoAction().getMultipleUsers(userIdArray);
- userIdArray.forEach(userId => {
- expect(response).to.haveOwnProperty(userId);
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement