Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
yimmyj committed Apr 4, 2024
1 parent 12a7891 commit 213ebfd
Showing 1 changed file with 89 additions and 89 deletions.
178 changes: 89 additions & 89 deletions tests/event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,96 +126,96 @@ describe('event creation', () => {
await expect(eventController.createEvent(createEventRequest, admin))
.rejects.toThrow('Start date after end date');
});
});

test('test non-conflicting event creation with re-used past attendance code', async () => {
const conn = await DatabaseConnection.get();
const admin = UserFactory.fake({ accessType: UserAccessType.ADMIN });
const user = UserFactory.fake();

await new PortalState()
.createUsers(admin, user)
.write();

const event = {
cover: 'https://www.google.com',
title: 'ACM Party @ RIMAC',
description: 'Indoor Pool Party',
location: 'RIMAC',
committee: 'ACM',
start: new Date('2050-08-20T10:00:00.000Z'),
end: new Date('2050-08-20T12:00:00.000Z'),
attendanceCode: 'ferris',
pointValue: 10,
};

const createEventRequest: CreateEventRequest = {
event,
};

const eventController = ControllerFactory.event(conn);
const eventResponse = await eventController.createEvent(createEventRequest, admin);

expect(eventResponse.event.cover).toEqual(event.cover);
expect(eventResponse.event.title).toEqual(event.title);
expect(eventResponse.event.location).toEqual(event.location);
expect(eventResponse.event.committee).toEqual(event.committee);
expect(eventResponse.event.title).toEqual(event.title);
expect(eventResponse.event.start).toEqual(event.start);
expect(eventResponse.event.end).toEqual(event.end);
expect(eventResponse.event.pointValue).toEqual(event.pointValue);

const lookupEvent = await eventController.getOneEvent({ uuid: eventResponse.event.uuid }, user);
expect(lookupEvent.error).toEqual(null);
expect(JSON.stringify(lookupEvent.event)).toEqual(JSON.stringify(eventResponse.event));
});
test('test non-conflicting event creation with re-used past attendance code', async () => {
const conn = await DatabaseConnection.get();
const admin = UserFactory.fake({ accessType: UserAccessType.ADMIN });
const user = UserFactory.fake();

await new PortalState()
.createUsers(admin, user)
.write();

const event = {
cover: 'https://www.google.com',
title: 'ACM Party @ RIMAC',
description: 'Indoor Pool Party',
location: 'RIMAC',
committee: 'ACM',
start: new Date('2050-08-20T10:00:00.000Z'),
end: new Date('2050-08-20T12:00:00.000Z'),
attendanceCode: 'ferris',
pointValue: 10,
};

const createEventRequest: CreateEventRequest = {
event,
};

const eventController = ControllerFactory.event(conn);
const eventResponse = await eventController.createEvent(createEventRequest, admin);

expect(eventResponse.event.cover).toEqual(event.cover);
expect(eventResponse.event.title).toEqual(event.title);
expect(eventResponse.event.location).toEqual(event.location);
expect(eventResponse.event.committee).toEqual(event.committee);
expect(eventResponse.event.title).toEqual(event.title);
expect(eventResponse.event.start).toEqual(event.start);
expect(eventResponse.event.end).toEqual(event.end);
expect(eventResponse.event.pointValue).toEqual(event.pointValue);

const lookupEvent = await eventController.getOneEvent({ uuid: eventResponse.event.uuid }, user);
expect(lookupEvent.error).toEqual(null);
expect(JSON.stringify(lookupEvent.event)).toEqual(JSON.stringify(eventResponse.event));
});

test('test conflicting event creation with re-used attendance code', async () => {
const conn = await DatabaseConnection.get();
const admin = UserFactory.fake({ accessType: UserAccessType.ADMIN });
const user = UserFactory.fake();

await new PortalState()
.createUsers(admin, user)
.write();

let event = {
cover: 'https://www.google.com',
title: 'ACM Party @ RIMAC',
description: 'Indoor Pool Party',
location: 'RIMAC',
committee: 'ACM',
start: new Date('2050-08-20T10:00:00.000Z'),
end: new Date('2050-08-20T12:00:00.000Z'),
attendanceCode: 'repeated',
pointValue: 10,
};

const createEventRequest: CreateEventRequest = {
event,
};

const eventController = ControllerFactory.event(conn);
await eventController.createEvent(createEventRequest, admin);

event = {
cover: 'https://www.google.com',
title: 'ACM Party @ RIMAC',
description: 'Indoor Pool Party',
location: 'RIMAC',
committee: 'ACM',
start: new Date('2050-08-20T09:00:00.000Z'),
end: new Date('2050-08-20T10:30:00.000Z'),
attendanceCode: 'repeated',
pointValue: 10,
};

const createEventRequest2: CreateEventRequest = {
event,
};

await expect(eventController.createEvent(createEventRequest2, admin))
.rejects.toThrow('There is a conflicting event with the same attendance code');
test('test conflicting event creation with re-used attendance code', async () => {
const conn = await DatabaseConnection.get();
const admin = UserFactory.fake({ accessType: UserAccessType.ADMIN });
const user = UserFactory.fake();

await new PortalState()
.createUsers(admin, user)
.write();

let event = {
cover: 'https://www.google.com',
title: 'ACM Party @ RIMAC',
description: 'Indoor Pool Party',
location: 'RIMAC',
committee: 'ACM',
start: new Date('2050-08-20T10:00:00.000Z'),
end: new Date('2050-08-20T12:00:00.000Z'),
attendanceCode: 'repeated',
pointValue: 10,
};

const createEventRequest: CreateEventRequest = {
event,
};

const eventController = ControllerFactory.event(conn);
await eventController.createEvent(createEventRequest, admin);

event = {
cover: 'https://www.google.com',
title: 'ACM Party @ RIMAC',
description: 'Indoor Pool Party',
location: 'RIMAC',
committee: 'ACM',
start: new Date('2050-08-20T09:00:00.000Z'),
end: new Date('2050-08-20T10:30:00.000Z'),
attendanceCode: 'repeated',
pointValue: 10,
};

const createEventRequest2: CreateEventRequest = {
event,
};

await expect(eventController.createEvent(createEventRequest2, admin))
.rejects.toThrow('There is a conflicting event with the same attendance code');
});
});

describe('event deletion', () => {
Expand Down Expand Up @@ -265,4 +265,4 @@ describe('event deletion', () => {

expect(repositoryEvent).toEqual(event);
});
});
});

0 comments on commit 213ebfd

Please sign in to comment.