Skip to content

Commit

Permalink
#2770-added invalid user id test
Browse files Browse the repository at this point in the history
  • Loading branch information
caiodasilva2005 committed Sep 20, 2024
1 parent 13ac9d8 commit 7081c60
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/backend/tests/unmocked/users.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Organization } from '@prisma/client';
import { createTestOrganization, createTestTask, createTestUser, resetUsers } from '../test-utils';
import { batmanAppAdmin } from '../test-data/users.test-data';
import UsersService from '../../src/services/users.services';
import { NotFoundException } from '../../src/utils/errors.utils';

describe('User Tests', () => {
let orgId: string;
Expand All @@ -15,11 +16,15 @@ describe('User Tests', () => {
await resetUsers();
});

describe('Get Users Tasks', () => {
it("Succeeds and gets user's assigned tasks", async () => {
const testBatman = await createTestUser(batmanAppAdmin, orgId);
const { task } = await createTestTask(testBatman, organization);
describe('Get Users Tasks', async () => {

Check failure on line 19 in src/backend/tests/unmocked/users.test.ts

View workflow job for this annotation

GitHub Actions / run-linting-check

No async describe callback
const testBatman = await createTestUser(batmanAppAdmin, orgId);
const { task } = await createTestTask(testBatman, organization);

it('fails on invalid user id', async () => {
expect(UsersService.getUserTasks('1', organization)).rejects.toThrow(new NotFoundException('User', '1'));

Check failure on line 24 in src/backend/tests/unmocked/users.test.ts

View workflow job for this annotation

GitHub Actions / run-linting-check

Async assertions must be awaited or returned
});

it("Succeeds and gets user's assigned tasks", async () => {
const userTasks = await UsersService.getUserTasks(testBatman.userId, organization);

expect(userTasks).toStrictEqual([task]);
Expand Down

0 comments on commit 7081c60

Please sign in to comment.