(client: PoolClient, email: string, verified = false)
| 10 | } from "../../helpers"; |
| 11 | |
| 12 | async function addEmail(client: PoolClient, email: string, verified = false) { |
| 13 | const { |
| 14 | rows: [row], |
| 15 | } = await client.query( |
| 16 | `insert into app_public.user_emails (email) values ($1) returning *`, |
| 17 | [email] |
| 18 | ); |
| 19 | if (verified) { |
| 20 | await asRoot(client, () => |
| 21 | client.query( |
| 22 | "update app_public.user_emails set is_verified = true where id = $1", |
| 23 | [row.id] |
| 24 | ) |
| 25 | ); |
| 26 | } |
| 27 | return row; |
| 28 | } |
| 29 | |
| 30 | it("can add an email (unverified), receive code, verify email (and marks account as verified)", () => |
| 31 | withUserDb(async (client, user) => { |
no test coverage detected