Skip to content

Commit

Permalink
github action
Browse files Browse the repository at this point in the history
  • Loading branch information
filipenevola committed Apr 2, 2024
1 parent 89688ab commit 73c16a7
Show file tree
Hide file tree
Showing 5 changed files with 684 additions and 7 deletions.
8 changes: 4 additions & 4 deletions group-call-002/EventsCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ const events = [
{
eventName: "Concert",
eventDate: "2024-05-15",
ticketsQty: 100,
quantity: 100,
eventStatus: "upcoming",
onlyVIPUsers: true,
},
{
eventName: "Conference",
eventDate: "2024-06-20",
ticketsQty: 200,
quantity: 200,
eventStatus: "past",
},
{
eventName: "Workshop",
eventDate: "2024-04-10",
ticketsQty: 50,
quantity: 50,
eventStatus: "past",
onlyVIPUsers: true,
},
{
eventName: "Festival",
eventDate: "2024-08-30",
ticketsQty: 500,
quantity: 500,
eventStatus: "upcoming",
},
];
Expand Down
4 changes: 2 additions & 2 deletions group-call-002/getTicketsAvailable.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function filterByDate(eventDate, event) {
}

function filterByQuantity(quantity, event) {
return !quantity || event.ticketsQty >= quantity;
return !quantity || event.quantity >= quantity;
}

function filterByUpcoming(event) {
Expand All @@ -37,7 +37,7 @@ function filterAvailableEvents({
);
}

export function getTicketsAvailable(userId, eventName, eventDate, quantity) {
export function getTicketsAvailable({userId, eventName, eventDate, quantity}) {
const user = UsersCollection.find().find((user) => user.userId === userId);

return EventsCollection.find().filter((event) => {
Expand Down
12 changes: 12 additions & 0 deletions group-call-002/getTicketsAvailable.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { getTicketsAvailable } from "./getTicketsAvailable.js";

describe("getTicketsAvailable", () => {
test("returns empty array when there are no events", () => {
const events = getTicketsAvailable({ eventName: "Con", quantity: 101 });
expect(events.length).toBe(0);
});
test("returns one event", () => {
const events = getTicketsAvailable({ userId: 1, eventName: "Con", quantity: 99 });
expect(events.length).toBe(1);
});
});
Loading

0 comments on commit 73c16a7

Please sign in to comment.