Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jho44 committed Feb 18, 2024
1 parent 2c31156 commit bb0a1fb
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 14 deletions.
38 changes: 31 additions & 7 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import AvailabilityDateRepository from '$lib/server/repository/AvailabilityDate';
import { AvailabilityStatus, PrismaClient, Pronoun } from '@prisma/client';
import { DateTime } from 'luxon';

Expand Down Expand Up @@ -313,14 +312,27 @@ async function main() {
}
);

await AvailabilityDateRepository.upsert({
householdId: 3,
date: firstDate.toJSDate(),

const firstDateBase = {
status: AvailabilityStatus.AVAILABLE,
notes: 'first date',
emoticons: '',
startTime: firstDate.set({ hour: 14 }).toJSDate(),
endTime: firstDate.set({ hour: 15 }).toJSDate()
};
await prisma.availabilityDate.upsert({
where: {
householdId_date: {
householdId: 3,
date: firstDate.toJSDate(),
}
},
update: firstDateBase,
create: {
householdId: 3,
date: firstDate.toJSDate(),
...firstDateBase
}
});

const lastDate = DateTime.fromObject(
Expand All @@ -334,14 +346,26 @@ async function main() {
}
);

await AvailabilityDateRepository.upsert({
householdId: 3,
date: lastDate.toJSDate(),
const lastDateBase = {
status: AvailabilityStatus.AVAILABLE,
notes: 'last date',
emoticons: '',
startTime: lastDate.set({ hour: 14 }).toJSDate(),
endTime: lastDate.set({ hour: 15 }).toJSDate()
};
await prisma.availabilityDate.upsert({
where: {
householdId_date: {
householdId: 3,
date: lastDate.toJSDate(),
}
},
update: lastDateBase,
create: {
householdId: 3,
date: lastDate.toJSDate(),
...lastDateBase
}
});
}

Expand Down
4 changes: 4 additions & 0 deletions src/lib/server/dbRoutes/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import acceptFriendReq from './acceptFriendReq';
import acceptHouseholdInvite from './acceptHouseholdInvite';
import createCircleInvite from './createCircleInvite';
import createHouseholdInvite from './createHouseholdInvite';
import createKid from './createKid';
import deleteFriend from './deleteFriend';
import deleteHouseholdInvite from './_shared/deleteHouseholdInvite';
import rejectFriendReq from './rejectFriendReq';
import rejectHouseholdInvite from './rejectHouseholdInvite';
import upsertDate from './upsertDate';
Expand All @@ -12,10 +14,12 @@ import upsertUser from './upsertUser';

export {
acceptFriendReq,
acceptHouseholdInvite,
createCircleInvite,
createHouseholdInvite,
createKid,
deleteFriend,
deleteHouseholdInvite,
rejectFriendReq,
rejectHouseholdInvite,
upsertDate,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { env as public_env } from '$env/dynamic/public';
import { writeReq } from '$lib/utils';
import { writeReq } from '$lib/logics/_shared/utils';
import { onMount } from 'svelte';
import intlTelInput from 'intl-tel-input';
Expand Down
2 changes: 1 addition & 1 deletion src/routes/circle/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { onMount, afterUpdate } from 'svelte';
import { page } from '$app/stores';
import { invalidate } from '$app/navigation';
import { writeReq } from '$lib/utils';
import { writeReq } from '$lib/logics/_shared/utils';
import NavBar from '$lib/components/NavBar.svelte';
import Modal from '$lib/components/Modal.svelte';
import PhoneInput from '$lib/components/PhoneInput.svelte';
Expand Down
6 changes: 2 additions & 4 deletions src/routes/db/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ export async function POST({
res = await routes[req.type](req, user);
return json(res);
} catch (err) {
console.error(err);
throw error(500, {
message: `${req.type} for user ${user.id} failed`
});
console.error(`${req.type} for user ${user.id} failed`);
throw error(err.status, err.body.message);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/routes/invites/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import AcceptIcon from '$lib/icons/checkIcon.svelte';
import NavBar from '$lib/components/NavBar.svelte';
import { invalidate } from '$app/navigation';
import { writeReq } from '$lib/utils';
import { writeReq } from '$lib/logics/_shared/utils';
let { friendReqsInfo, householdInvites } = $page.data;
afterUpdate(() => {
Expand Down

0 comments on commit bb0a1fb

Please sign in to comment.