diff options
author | Hailey <me@haileyok.com> | 2024-09-30 13:56:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-30 13:56:49 -0700 |
commit | 669cdf222cf13ad07f3ec48fd4f32b64fa52ab88 (patch) | |
tree | cc53e66f419b7d5380f298f10a46d8f5a2b830bf /__tests__ | |
parent | 66f3068c583b2e9d0388c10804ecaa7086cd549a (diff) | |
download | voidsky-669cdf222cf13ad07f3ec48fd4f32b64fa52ab88.tar.zst |
Move email test to root tests dir (#5527)
Diffstat (limited to '__tests__')
-rw-r--r-- | __tests__/lib/email.test.ts | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/__tests__/lib/email.test.ts b/__tests__/lib/email.test.ts new file mode 100644 index 000000000..4dfda658f --- /dev/null +++ b/__tests__/lib/email.test.ts @@ -0,0 +1,82 @@ +import {describe, expect, it} from '@jest/globals' +import tldts from 'tldts' + +import {isEmailMaybeInvalid} from '#/lib/strings/email' + +describe('emailTypoChecker', () => { + const invalidCases = [ + 'gnail.com', + 'gnail.co', + 'gmaill.com', + 'gmaill.co', + 'gmai.com', + 'gmai.co', + 'gmal.com', + 'gmal.co', + 'gmail.co', + 'iclod.com', + 'iclod.co', + 'outllok.com', + 'outllok.co', + 'outlook.co', + 'yaoo.com', + 'yaoo.co', + 'yaho.com', + 'yaho.co', + 'yahooo.com', + 'yahooo.co', + 'yahoo.co', + 'hithere.jul', + 'agpowj.notshop', + 'thisisnot.avalid.tld.nope', + // old tld for czechoslovakia + 'czechoslovakia.cs', + // tlds that cbs was registering in 2024 but cancelled + 'liveon.cbs', + 'its.showtime', + ] + const validCases = [ + 'gmail.com', + // subdomains (tests end of string) + 'gnail.com.test.com', + 'outlook.com', + 'yahoo.com', + 'icloud.com', + 'firefox.com', + 'firefox.co', + 'hello.world.com', + 'buy.me.a.coffee.shop', + 'mayotte.yt', + 'aland.ax', + 'bouvet.bv', + 'uk.gb', + 'chad.td', + 'somalia.so', + 'plane.aero', + 'cute.cat', + 'together.coop', + 'findme.jobs', + 'nightatthe.museum', + 'industrial.mil', + 'czechrepublic.cz', + 'lovakia.sk', + // new gtlds in 2024 + 'whatsinyour.locker', + 'letsmakea.deal', + 'skeet.now', + 'everyone.みんな', + 'bourgeois.lifestyle', + 'california.living', + 'skeet.ing', + 'listeningto.music', + 'createa.meme', + ] + + it.each(invalidCases)(`should be invalid: abcde@%s`, domain => { + expect(isEmailMaybeInvalid(`abcde@${domain}`, tldts)).toEqual(true) + }) + + it.each(validCases)(`should be valid: abcde@%s`, domain => { + expect(isEmailMaybeInvalid(`abcde@${domain}`, tldts)).toEqual(false) + }) +}) |