daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import errorTest from "@microtica/mocha-error-test";
  2. import { assert, expect } from "chai";
  3. import * as HTTPStatus from "http-status-codes";
  4. import { CognitoAction } from "../../actions/cognito";
  5. const userIdArray: string[] = [];
  6. describe("Unit", () => {
  7.  
  8.     it("Cognito Action Sign Up User Success", async () => {
  9.         const username = "testUsername";
  10.         const password = "testPassword";
  11.         await new CognitoAction().singUpUser(username, password);
  12.     });
  13.  
  14.     it("Cognito Action Sign Up User Fail", async () => {
  15.         const username = "testUsername";
  16.         const password = "testPassword";
  17.         await errorTest(
  18.             assert,
  19.             new CognitoAction().singUpUser(username, password),
  20.             HTTPStatus.BAD_REQUEST,
  21.             "Should not be able to create a user with a used Username"
  22.         );
  23.     });
  24.  
  25.     it("Cognito Action Confirm Sign Up Success", async () => {
  26.         const username = "testUsername";
  27.         const code = "112233";
  28.         await new CognitoAction().confirmSignUp(username, code);
  29.     });
  30.  
  31.     it("Cognito Action Login User Success", async () => {
  32.         const username = "testUsername";
  33.         const password = "testPassword";
  34.         const response = await new CognitoAction().loginUser(username, password);
  35.         expect(response.done).to.equal(true);
  36.     });
  37.  
  38.     it("Cognito Action Login User fail", async () => {
  39.         const failUsername = "testUsernameFail";
  40.         const password = "testPassword";
  41.         await errorTest(
  42.             assert,
  43.             new CognitoAction().loginUser(failUsername, password),
  44.             HTTPStatus.BAD_REQUEST,
  45.             "Should fail to log in with wrong credentials"
  46.         );
  47.     });
  48.  
  49.     it("Cognito Action Set Password Success", async () => {
  50.         const username = "testUsername";
  51.         const password = "testPassword";
  52.         const sessionToken = "someSessionToken";
  53.         const response = await new CognitoAction().setPassword(username, password, sessionToken);
  54.         expect(response.done).to.equal(true);
  55.     });
  56.  
  57.     it("Cognito Action Create Multiple Users Success", async () => {
  58.         const usernames = ["testUsername000", "testUsername001", "testUsername002", "testUsername003"];
  59.         const response = await new CognitoAction().createMultipleUsers(usernames);
  60.         usernames.forEach(username => {
  61.             userIdArray.push(response[username].id);
  62.             expect(response).to.haveOwnProperty(username);
  63.         });
  64.     });
  65.  
  66.     it("Cognito Action Create User Success", async () => {
  67.         const username = "newTestUsername";
  68.         const response = await new CognitoAction().createUser(username);
  69.         expect(response.done).to.equal(true);
  70.     });
  71.  
  72.     it("Cognito Action Get Multiple Users Success", async () => {
  73.         const response = await new CognitoAction().getMultipleUsers(userIdArray);
  74.         userIdArray.forEach(userId => {
  75.             expect(response).to.haveOwnProperty(userId);
  76.         });
  77.     });
  78.  
  79. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top