ekyc

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

email.test.ts (1012B)


      1 import { assertThrows } from "$std/assert/assert_throws.ts";
      2 import { Email, InvalidEmail } from "#core/domain/email.ts";
      3 
      4 const INVALID_EMAILS = [
      5   "",
      6   "   ",
      7   "welcome",
      8   "   doydy1@bfh.ch",
      9   "\t",
     10   "hello👍@gmail.com",
     11 ];
     12 
     13 const VALID_EMAILS = [
     14   "doydy1@bfh.ch",
     15   "yannmickael.doy@students.bfh.ch",
     16   "simple@example.com",
     17   "very.common@example.com",
     18   "abc@example.co.uk",
     19   "disposable.style.email.with+symbol@example.com",
     20   "other.email-with-hyphen@example.com",
     21   "fully-qualified-domain@example.com",
     22   "user.name+tag+sorting@example.com",
     23   "example-indeed@strange-example.com",
     24 ];
     25 
     26 Deno.test({
     27   name: `unit email valid should be accepted`,
     28   fn() {
     29     for (const candidate of VALID_EMAILS) {
     30       const act = () => new Email(candidate);
     31       act();
     32     }
     33   },
     34 });
     35 
     36 Deno.test({
     37   name: `unit email invalid shouldn't be accepted`,
     38   fn() {
     39     for (const candidate of INVALID_EMAILS) {
     40       const act = () => new Email(candidate);
     41       assertThrows(act, InvalidEmail);
     42     }
     43   },
     44 });