calcom/test/lib/prisma.test.ts
Alex Johansson f63aa5d550
add linting in CI + fix lint errors (#473)
* run `yarn lint --fix`

* Revert "Revert "add linting to ci""

This reverts commit 0bbbbee4be.

* Fixed some errors

* remove unused code - not sure why this was here?

* assert env var

* more type fixes

* fix typings og gcal callback - needs testing

* rename `md5.ts` to `md5.js`

it is js.

* fix types

* fix types

* fix lint errors

* fix last lint error

Co-authored-by: Alex van Andel <me@alexvanandel.com>
2021-08-19 14:27:01 +02:00

91 lines
1.9 KiB
TypeScript

import { expect, it } from "@jest/globals";
import { whereAndSelect } from "@lib/prisma";
it("can decorate using whereAndSelect", async () => {
whereAndSelect(
(queryObj) => {
expect(queryObj).toStrictEqual({ where: { id: 1 }, select: { example: true } });
},
{ id: 1 },
["example"]
);
});
it("can do nested selects using . seperator", async () => {
whereAndSelect(
(queryObj) => {
expect(queryObj).toStrictEqual({
where: {
uid: 1,
},
select: {
description: true,
attendees: {
select: {
email: true,
name: true,
},
},
},
});
},
{ uid: 1 },
["description", "attendees.email", "attendees.name"]
);
});
it("can handle nesting deeply", async () => {
whereAndSelect(
(queryObj) => {
expect(queryObj).toStrictEqual({
where: {
uid: 1,
},
select: {
description: true,
attendees: {
select: {
email: {
select: {
nested: true,
},
},
name: true,
},
},
},
});
},
{ uid: 1 },
["description", "attendees.email.nested", "attendees.name"]
);
});
it("can handle nesting multiple", async () => {
whereAndSelect(
(queryObj) => {
expect(queryObj).toStrictEqual({
where: {
uid: 1,
},
select: {
description: true,
attendees: {
select: {
email: true,
name: true,
},
},
bookings: {
select: {
id: true,
name: true,
},
},
},
});
},
{ uid: 1 },
["description", "attendees.email", "attendees.name", "bookings.id", "bookings.name"]
);
});