mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-10-31 10:19:43 +00:00
fix(tests): narrow redeemed profile
Assert that the profile lookup returned a row before reading premium status so Deno strict type checking can execute the Supabase integration suite.
This commit is contained in:
1 parent
d43ae1ef05
commit
d869592a8b
1 file changed
+14
-7
@@ -1,6 +1,11 @@
|
||||
|
||||
import { assertEquals } from "std/testing/asserts.ts";
|
||||
import { createTestUser, createRedemptionCode, cleanup, adminClient, SUPABASE_URL } from "./utils.ts";
|
||||
import { assertEquals, assertExists } from "std/testing/asserts.ts";
|
||||
import {
|
||||
adminClient,
|
||||
cleanup,
|
||||
createRedemptionCode,
|
||||
createTestUser,
|
||||
SUPABASE_URL,
|
||||
} from "./utils.ts";
|
||||
|
||||
const FUNCTION_URL = `${SUPABASE_URL}/functions/v1/redeem-code`;
|
||||
|
||||
@@ -24,8 +29,8 @@ Deno.test("redeem-code: successfully redeems code for user", async () => {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
code: codeData.code
|
||||
})
|
||||
code: codeData.code,
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
@@ -39,10 +44,12 @@ Deno.test("redeem-code: successfully redeems code for user", async () => {
|
||||
.eq("id", user.id)
|
||||
.single();
|
||||
|
||||
assertExists(profile);
|
||||
assertEquals(profile.is_premium, true);
|
||||
|
||||
} finally {
|
||||
await cleanup(userIds);
|
||||
if (codeId) await adminClient.from("redemption_codes").delete().eq("id", codeId);
|
||||
if (codeId) {
|
||||
await adminClient.from("redemption_codes").delete().eq("id", codeId);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user