Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update project registration #627

Closed
wants to merge 14 commits into from
8 changes: 4 additions & 4 deletions packages/api/tests/api/project/post.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,18 @@ describe('project post endpoint', () => {
expect(req.entityManager.transactional).not.toBeCalled();
});

it('should throw an error of project not created', async () => {
it('should throw an error if project not created', async () => {
const data = { name: 'A cool project' };
validatePayloadMock.mockReturnValueOnce({ errorHandled: false, data } as any);
const req = createMockRequest();
const req = createMockRequest({ user: { id: '1' } as any });
const res = createMockResponse();
(req.entityManager.transactional as jest.Mock).mockResolvedValueOnce(undefined);
(axios.get as jest.Mock).mockResolvedValueOnce({ status: 200 });
(Project.prototype.constructor as jest.Mock).mockReturnValueOnce(undefined);

await post(req as any, res as any);

expect(req.entityManager.transactional).toBeCalledTimes(1);
expect(req.entityManager.findOneOrFail).not.toBeCalled();
expect(req.entityManager.findOneOrFail).toHaveBeenCalled();
expect(req.entityManager.persist).not.toBeCalled();
expect(res.sendStatus).toHaveBeenCalledWith(500);
});
Expand Down
Loading