Skip to content

Commit

Permalink
#3124 fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chpy04 committed Jan 25, 2025
1 parent 74ccba9 commit c2e2387
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
22 changes: 16 additions & 6 deletions src/backend/tests/unit/recruitment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ describe('Recruitment Tests', () => {

describe('Get All FAQs', () => {
it('Succeeds and gets all the FAQs', async () => {
const faq1 = await RecruitmentServices.createFaq(
const faq1 = await RecruitmentServices.createOrganizationFaq(
await createTestUser(batmanAppAdmin, orgId),
'question',
'answer',
organization
);
const faq2 = await RecruitmentServices.createFaq(
const faq2 = await RecruitmentServices.createOrganizationFaq(
await createTestUser(supermanAdmin, orgId),
'question2',
'answer2',
organization
);
const result = await RecruitmentServices.getAllFaqs(organization);
const result = await RecruitmentServices.getAllOrganizationFaqs(organization);
expect(result).toStrictEqual([faq1, faq2]);
});

Expand Down Expand Up @@ -233,7 +233,12 @@ describe('Recruitment Tests', () => {
it('Fails if user is not an admin', async () => {
await expect(
async () =>
await RecruitmentServices.createFaq(await createTestUser(member, orgId), 'question', 'answer', organization)
await RecruitmentServices.createOrganizationFaq(
await createTestUser(member, orgId),
'question',
'answer',
organization
)
).rejects.toThrow(new AccessDeniedAdminOnlyException('create an faq'));
});

Expand Down Expand Up @@ -279,12 +284,17 @@ describe('Recruitment Tests', () => {
it('Fails if user is not an admin', async () => {
await expect(
async () =>
await RecruitmentServices.createFaq(await createTestUser(member, orgId), 'question', 'answer', organization)
await RecruitmentServices.createOrganizationFaq(
await createTestUser(member, orgId),
'question',
'answer',
organization
)
).rejects.toThrow(new AccessDeniedAdminOnlyException('create an faq'));
});

it('Succeeds and creates an FAQ', async () => {
const result = await RecruitmentServices.createFaq(
const result = await RecruitmentServices.createOrganizationFaq(
await createTestUser(batmanAppAdmin, orgId),
'question',
'answer',
Expand Down
22 changes: 16 additions & 6 deletions src/backend/tests/unmocked/recruitment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ describe('Recruitment Tests', () => {

describe('Get All FAQs', () => {
it('Succeeds and gets all the FAQs', async () => {
const faq1 = await RecruitmentServices.createFaq(
const faq1 = await RecruitmentServices.createOrganizationFaq(
await createTestUser(batmanAppAdmin, orgId),
'question',
'answer',
organization
);
const faq2 = await RecruitmentServices.createFaq(
const faq2 = await RecruitmentServices.createOrganizationFaq(
await createTestUser(supermanAdmin, orgId),
'question2',
'answer2',
organization
);
const result = await RecruitmentServices.getAllFaqs(organization);
const result = await RecruitmentServices.getAllOrganizationFaqs(organization);
expect(result).toStrictEqual([faq1, faq2]);
});

Expand Down Expand Up @@ -233,7 +233,12 @@ describe('Recruitment Tests', () => {
it('Fails if user is not an admin', async () => {
await expect(
async () =>
await RecruitmentServices.createFaq(await createTestUser(member, orgId), 'question', 'answer', organization)
await RecruitmentServices.createOrganizationFaq(
await createTestUser(member, orgId),
'question',
'answer',
organization
)
).rejects.toThrow(new AccessDeniedAdminOnlyException('create an faq'));
});

Expand Down Expand Up @@ -279,12 +284,17 @@ describe('Recruitment Tests', () => {
it('Fails if user is not an admin', async () => {
await expect(
async () =>
await RecruitmentServices.createFaq(await createTestUser(member, orgId), 'question', 'answer', organization)
await RecruitmentServices.createOrganizationFaq(
await createTestUser(member, orgId),
'question',
'answer',
organization
)
).rejects.toThrow(new AccessDeniedAdminOnlyException('create an faq'));
});

it('Succeeds and creates an FAQ', async () => {
const result = await RecruitmentServices.createFaq(
const result = await RecruitmentServices.createOrganizationFaq(
await createTestUser(batmanAppAdmin, orgId),
'question',
'answer',
Expand Down

0 comments on commit c2e2387

Please sign in to comment.