Skip to content

Commit

Permalink
add relationship tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Feb 14, 2024
1 parent 95f44e3 commit 88ec459
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
9 changes: 1 addition & 8 deletions src/lib/__tests__/relationships.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@ describe('Relationships Module', () => {

const relationship = await createRelationship({ supabase: runtime.supabase, userA, userB });

expect(relationship).toBeDefined();

if (relationship?.length === 0) {
throw new Error('No relationship was created');
}

expect(relationship[0].user_a).toBe(userA);
expect(relationship[0].user_b).toBe(userB);
expect(relationship).toBe(true);
});

test('getRelationship retrieves an existing relationship', async () => {
Expand Down
7 changes: 4 additions & 3 deletions src/lib/relationships.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ export async function createRelationship({
supabase: SupabaseClient;
userA: UUID;
userB: UUID;
}): Promise<Relationship[]> {
const { data, error } = await supabase.from("relationships").upsert({
}): Promise<boolean> {
const { error } = await supabase.from("relationships").upsert({
user_a: userA,
user_b: userB,
user_id: userA,
});

if (error) {
throw new Error(error.message);
}

return data as unknown as Relationship[];
return true
}

export async function getRelationship({
Expand Down

0 comments on commit 88ec459

Please sign in to comment.