ekyc

Electronic KYC process with uploading ID document using OAuth 2.1 (experimental)
Log | Files | Refs | README | LICENSE

auth_register.test.ts (2123B)


      1 import { EntityNotFound } from "../core/application/repository_error.ts";
      2 import { assertEquals } from "$std/assert/assert_equals.ts";
      3 import { assertThrows } from "$std/assert/assert_throws.ts";
      4 import { beforeEach, describe, it } from "$std/testing/bdd.ts";
      5 import { createAppForAcceptanceTest } from "./acceptance.ts";
      6 import { UUID } from "#core/domain/uuid.ts";
      7 
      8 describe("given auth register use case for acceptance test", () => {
      9   let app: ReturnType<typeof createAppForAcceptanceTest>;
     10 
     11   beforeEach(() => {
     12     app = createAppForAcceptanceTest();
     13   });
     14 
     15   describe("when register with valid sample", () => {
     16     const given = () =>
     17       app.authRegister.execute({
     18         email: "doydy1@bfh.ch",
     19         password: "password",
     20         passwordConfirmation: "password",
     21       });
     22 
     23     it("then should be registered and persisted", async () => {
     24       const act = await given();
     25       assertEquals(act.status, "registered");
     26     });
     27 
     28     it("then should be persisted", async () => {
     29       const background = await given();
     30       const act = app.authRepo.find(new UUID(background.uuid!));
     31       assertEquals(act.email.address.toString(), "doydy1@bfh.ch");
     32     });
     33 
     34     it("the cannot be register twice", async () => {
     35       await given();
     36       const act = await given();
     37       assertEquals(act.status, "conflict");
     38     });
     39   });
     40 
     41   describe("when register with invalid email sample", () => {
     42     const given = () =>
     43       app.authRegister.execute({
     44         email: "invalid email",
     45         password: "password",
     46         passwordConfirmation: "password",
     47       });
     48 
     49     it("then should be rejected with invalid", async () => {
     50       const act = await given();
     51       assertEquals(act.status, "invalid");
     52     });
     53   });
     54 
     55   describe("when register with invalid password sample", () => {
     56     const given = () =>
     57       app.authRegister.execute({
     58         email: "doydy1@bfh.ch",
     59         password: "password",
     60         passwordConfirmation: "invalid confirm",
     61       });
     62 
     63     it("then should be rejected with invalid", async () => {
     64       const act = await given();
     65       assertEquals(act.status, "invalid");
     66     });
     67   });
     68 });