Skip to content

Commit

Permalink
merchOrder test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwn04 committed Apr 2, 2024
1 parent 44df26f commit f93595a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ describe('event creation', () => {
const eventController = ControllerFactory.event(conn, instance(storageService));
await expect(eventController.createEvent(cover, createEventRequest, user))
.rejects.toThrow(ForbiddenError);
verify(storageService.deleteAtUrl(fileLocation)).called();
});

test('throws error when start date later than end date', async () => {
Expand Down Expand Up @@ -147,6 +146,7 @@ describe('event creation', () => {
const eventController = ControllerFactory.event(conn, instance(storageService));
await expect(eventController.createEvent(cover, createEventRequest, admin))
.rejects.toThrow('Start date after end date');
verify(storageService.deleteAtUrl(fileLocation)).called();
});
});

Expand Down
13 changes: 10 additions & 3 deletions tests/merchOrder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { ControllerFactory } from './controllers';
import { DatabaseConnection, EventFactory, MerchFactory, PortalState, UserFactory } from './data';
import { MerchStoreControllerWrapper } from './controllers/MerchStoreControllerWrapper';
import { UserModel } from '../models/UserModel';
import { FileFactory } from './data/FileFactory';
import Mocks from './mocks/MockFactory';
import { Config } from '../config';

beforeAll(async () => {
await DatabaseConnection.connect();
Expand Down Expand Up @@ -902,6 +905,8 @@ describe('merch orders', () => {
});

describe('merch order pickup events', () => {
const fileLocation = 'https://s3.amazonaws.com/event-cover.jpg';

test('past, future, and individual pickup events can be retrieved', async () => {
const conn = await DatabaseConnection.get();
const merchDistributor = UserFactory.fake({ accessType: UserAccessType.MERCH_STORE_DISTRIBUTOR });
Expand Down Expand Up @@ -972,8 +977,10 @@ describe('merch order pickup events', () => {
const merchDistributor = UserFactory.fake({ accessType: UserAccessType.MERCH_STORE_DISTRIBUTOR });
const admin = UserFactory.fake({ accessType: UserAccessType.ADMIN });
const linkedEvent = EventFactory.fake();
const eventController = ControllerFactory.event(conn);
await eventController.createEvent({ event: linkedEvent }, admin);
const cover = FileFactory.image(Config.file.MAX_EVENT_COVER_FILE_SIZE / 2);
const storageService = Mocks.storage(fileLocation);
const eventController = ControllerFactory.event(conn, instance(storageService));
await eventController.createEvent(cover, { event: linkedEvent }, admin);

const pickupEvent = MerchFactory.fakeFutureOrderPickupEvent({ linkedEvent });

Expand All @@ -996,7 +1003,7 @@ describe('merch order pickup events', () => {
// edit a linked event

const newLinkedEvent = EventFactory.fake();
await eventController.createEvent({ event: newLinkedEvent }, admin);
await eventController.createEvent(cover, { event: newLinkedEvent }, admin);

const editPickupEventRequest = { pickupEvent: { linkedEventUuid: newLinkedEvent.uuid } };
const params = { uuid: pickupEvent.uuid };
Expand Down

0 comments on commit f93595a

Please sign in to comment.