-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
group-call-002 - TicketFilters enum test
- Loading branch information
1 parent
7776b2b
commit bee8845
Showing
4 changed files
with
63 additions
and
30 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
export const TicketFilters = { | ||
BY_NAME: { | ||
propName: 'eventName', | ||
isRequired: false, | ||
execute({query: {eventName}, event}) { | ||
return !eventName || event.eventName.includes(eventName); | ||
}, | ||
}, | ||
BY_DATE: { | ||
propName: 'eventDate', | ||
isRequired: false, | ||
execute({query: {eventDate}, event}) { | ||
return !eventDate || event.eventDate === eventDate; | ||
}, | ||
}, | ||
BY_QUANTITY: { | ||
propName: 'quantity', | ||
isRequired: true, | ||
execute({query: {quantity}, event}) { | ||
return !quantity || event.quantity >= quantity; | ||
}, | ||
}, | ||
BY_STATUS: { | ||
propName: 'status', | ||
isRequired: false, | ||
execute({query: {status}, event}) { | ||
return !status || event.eventStatus === status; | ||
}, | ||
}, | ||
BY_USER_VIP: { | ||
propName: 'quantity', | ||
isRequired: false, | ||
execute({event, user}) { | ||
return user?.isVIP || !event.onlyVIPUsers; | ||
}, | ||
}, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { TicketFilters } from "./TicketFilters.js"; | ||
|
||
describe("TicketFilters", () => { | ||
test("isRequired is present", () => { | ||
Object.values(TicketFilters).forEach(({ isRequired }) => { | ||
expect(isRequired).toBeDefined(); | ||
}); | ||
}); | ||
test("propName is present", () => { | ||
Object.values(TicketFilters).forEach(({ propName }) => { | ||
expect(propName).toBeDefined(); | ||
}); | ||
}); | ||
}); |
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