all repos — caroster @ 319a37b5975c4983a15f2c9184558c81cee2fca9

[Octree] Group carpool to your event https://caroster.io

e2e/tests/3.event.test.ts (view raw)

  1import { EVENT, EVENT_ID, EVENT_UUID } from "../constants";
  2import { sdk } from "../lib/gqlSdk";
  3
  4test("createEvent returns created event with minimal parameters", async () => {
  5  const eventData = {
  6    email: "test+event@octree.ch",
  7    name: "Test event",
  8  };
  9  const request = sdk.createEvent({ eventData });
 10
 11  await expect(request).resolves.toMatchObject({
 12    createEvent: {
 13      data: {
 14        id: expect.stringMatching(/\d/),
 15        attributes: {
 16          waitingPassengers: { data: [] },
 17          ...eventData,
 18        },
 19      },
 20    },
 21  });
 22});
 23
 24test("createEvent returns created event with all parameters", async () => {
 25  const eventData = {
 26    email: "test+event@octree.ch",
 27    name: "Test event",
 28    address: "Test address",
 29    date: "2032-10-03",
 30    description: "Test event description",
 31  };
 32  const request = sdk.createEvent({ eventData });
 33
 34  await expect(request).resolves.toMatchObject({
 35    createEvent: {
 36      data: {
 37        id: expect.stringMatching(/\d/),
 38        attributes: {
 39          waitingPassengers: { data: [] },
 40          ...eventData,
 41        },
 42      },
 43    },
 44  });
 45});
 46
 47test("updateEvent returns updated event", async () => {
 48  const updatedName = "My Caroster event";
 49  const request = sdk.updateEvent({
 50    uuid: EVENT_UUID,
 51    eventUpdate: {
 52      name: updatedName,
 53    },
 54  });
 55
 56  await expect(request).resolves.toMatchObject({
 57    updateEventByUUID: {
 58      data: {
 59        id: EVENT_ID,
 60        attributes: {
 61          description: EVENT.description,
 62          name: updatedName,
 63        },
 64      },
 65    },
 66  });
 67});
 68
 69test("updateEvent throws error if UUID doesn´t exist", async () => {
 70  const request = sdk.updateEvent({
 71    uuid: "uuid-that-not-exists",
 72    eventUpdate: {
 73      name: "random name",
 74    },
 75  });
 76
 77  await expect(request).rejects.toThrow();
 78});
 79
 80test("eventByUUID returns event corresponding to UUID", async () => {
 81  const request = sdk.eventByUUID({
 82    uuid: EVENT_UUID,
 83  });
 84
 85  await expect(request).resolves.toMatchObject({
 86    eventByUUID: {
 87      data: {
 88        id: EVENT_ID,
 89      },
 90    },
 91  });
 92});
 93
 94test("eventByUUID fails if UUID doesn't exist", async () => {
 95  const request = sdk.eventByUUID({
 96    uuid: "uuid-that-not-exists",
 97  });
 98
 99  await expect(request).rejects.toThrow();
100});