-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a signup timestamp to the EventReservation Type (#784)
Updated tests as well
- Loading branch information
1 parent
0a1f8c1
commit 958a353
Showing
8 changed files
with
49 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,22 +10,24 @@ import { Timestamp } from "firebase-admin/firestore" | |
|
||
const eventService = new EventService() | ||
|
||
const startDate = dateToFirestoreTimeStamp(new Date(2024, 1, 1)) | ||
const endDate = dateToFirestoreTimeStamp(new Date(2024, 1, 2)) | ||
const startDate = new Date(2024, 1, 1) | ||
const endDate = new Date(2024, 1, 2) | ||
const startTimestamp = dateToFirestoreTimeStamp(startDate) | ||
const endTimestamp = dateToFirestoreTimeStamp(endDate) | ||
|
||
const event1: Event = { | ||
title: "UASC new event", | ||
description: "Grand opening of the website.", | ||
location: "Virtual pizza event", | ||
start_date: startDate, | ||
end_date: endDate | ||
start_date: startTimestamp, | ||
end_date: endTimestamp | ||
} | ||
const event2: Event = { | ||
title: "Snowboard racing", | ||
description: "Race and see who's the fastest!", | ||
location: "Snowsport club", | ||
start_date: startDate, | ||
end_date: endDate | ||
start_date: startTimestamp, | ||
end_date: endTimestamp | ||
} | ||
const now = new Date(Date.now()) | ||
const futureEvent: Event = { | ||
|
@@ -39,13 +41,15 @@ const reservation1: EventReservation = { | |
first_name: "John", | ||
last_name: "Appleseed", | ||
email: "[email protected]", | ||
is_member: true | ||
is_member: true, | ||
timestamp: Timestamp.fromDate(startDate) | ||
} | ||
const reservation2: EventReservation = { | ||
first_name: "Jane", | ||
last_name: "Pearseed", | ||
email: "[email protected]", | ||
is_member: false | ||
is_member: false, | ||
timestamp: Timestamp.fromDate(startDate) | ||
} | ||
|
||
describe("EventService integration tests", () => { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import EventService from "data-layer/services/EventService" | |
import { request } from "../routes.setup" | ||
import { Event, EventReservation } from "../../data-layer/models/firebase" | ||
import { dateToFirestoreTimeStamp } from "data-layer/adapters/DateUtils" | ||
import { Timestamp } from "firebase-admin/firestore" | ||
|
||
const startDate = dateToFirestoreTimeStamp(new Date(2024, 1, 1)) | ||
const endDate = dateToFirestoreTimeStamp(new Date(2024, 1, 2)) | ||
|
@@ -11,7 +12,7 @@ const event1: Event = { | |
start_date: startDate, | ||
end_date: endDate | ||
} | ||
const reservation1: EventReservation = { | ||
const reservation1: Omit<EventReservation, "timestamp"> = { | ||
first_name: "John", | ||
last_name: "Doe", | ||
email: "[email protected]", | ||
|
@@ -44,7 +45,10 @@ describe("EventController endpoint tests", () => { | |
|
||
it("should return 400 if already signed up to event", async () => { | ||
const event = await eventService.createEvent(event1) | ||
await eventService.addReservation(event.id, reservation1) | ||
await eventService.addReservation(event.id, { | ||
...reservation1, | ||
timestamp: Timestamp.now() | ||
}) | ||
const res = await request.post("/events/signup").send({ | ||
event_id: event.id, | ||
reservation: reservation1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters