mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-10-31 18: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, assertExists } from "std/testing/asserts.ts";
|
||||||
import { assertEquals } from "std/testing/asserts.ts";
|
import {
|
||||||
import { createTestUser, createRedemptionCode, cleanup, adminClient, SUPABASE_URL } from "./utils.ts";
|
adminClient,
|
||||||
|
cleanup,
|
||||||
|
createRedemptionCode,
|
||||||
|
createTestUser,
|
||||||
|
SUPABASE_URL,
|
||||||
|
} from "./utils.ts";
|
||||||
|
|
||||||
const FUNCTION_URL = `${SUPABASE_URL}/functions/v1/redeem-code`;
|
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" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
email,
|
email,
|
||||||
code: codeData.code
|
code: codeData.code,
|
||||||
})
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
@@ -39,10 +44,12 @@ Deno.test("redeem-code: successfully redeems code for user", async () => {
|
|||||||
.eq("id", user.id)
|
.eq("id", user.id)
|
||||||
.single();
|
.single();
|
||||||
|
|
||||||
|
assertExists(profile);
|
||||||
assertEquals(profile.is_premium, true);
|
assertEquals(profile.is_premium, true);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
await cleanup(userIds);
|
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