Skip to content

Commit

Permalink
ci: add assertions to tests with no assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
gulfaraz committed Sep 30, 2024
1 parent 9e4fc39 commit 5425539
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ describe('Should send an email for phl dengue', () => {
});

it('trigger', async () => {
await testDengueScenario(
const result = await testDengueScenario(
EpidemicsScenario.Trigger,
countryCodeISO3,
accessToken,
);
expect(result).toBeTruthy();
});

it('no-trigger', async () => {
await testDengueScenario(
const result = await testDengueScenario(
EpidemicsScenario.NoTrigger,
countryCodeISO3,
accessToken,
);
expect(result).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function testDengueScenario(
scenario: EpidemicsScenario,
countryCodeISO3: string,
accessToken: string,
): Promise<void> {
): Promise<boolean> {
const eventNames = ['0-month', '1-month', '2-month'];
const disasterTypeLabel = DisasterType.Dengue;

Expand Down Expand Up @@ -67,4 +67,6 @@ export async function testDengueScenario(
expect(hasEvent).toBe(true);
}
}

return true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ describe('Should send an email for mwi flash flood', () => {
});

it('trigger', async () => {
await testFlashFloodScenario(
const result = await testFlashFloodScenario(
FlashFloodsScenario.Trigger,
countryCodeISO3,
accessToken,
);
expect(result).toBeTruthy();
});

it('no-trigger', async () => {
await testFlashFloodScenario(
const result = await testFlashFloodScenario(
FlashFloodsScenario.NoTrigger,
countryCodeISO3,
accessToken,
);
expect(result).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function testFlashFloodScenario(
scenario: FlashFloodsScenario,
countryCodeISO3: string,
accessToken: string,
): Promise<void> {
): Promise<boolean> {
const eventNames = ['Rumphi', 'Karonga'];
const disasterTypeLabel = 'Flash Flood'; // DisasterType.FlashFloods does not match

Expand Down Expand Up @@ -67,4 +67,6 @@ export async function testFlashFloodScenario(
expect(hasEvent).toBe(true);
}
}

return true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ describe('Should send an email for ssd floods', () => {

it('trigger', async () => {
const events = [{ eventName: 'G5100', leadTime: '4-day' }];
await testFloodScenario(FloodsScenario.Trigger, {
const result = await testFloodScenario(FloodsScenario.Trigger, {
events,
countryCodeISO3,
accessToken,
});
expect(result).toBeTruthy();
});

it('no-trigger', async () => {
const events = [];
await testFloodScenario(FloodsScenario.NoTrigger, {
const result = await testFloodScenario(FloodsScenario.NoTrigger, {
events,
countryCodeISO3,
accessToken,
});
expect(result).toBeTruthy();
});
});
12 changes: 8 additions & 4 deletions services/API-service/test/email/floods/email-uga-floods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,41 @@ describe('Should send an email for uga floods', () => {
{ eventName: 'G5220', leadTime: '4-day' },
{ eventName: 'G5230', leadTime: '6-day' },
];
await testFloodScenario(FloodsScenario.Trigger, {
const result = await testFloodScenario(FloodsScenario.Trigger, {
events,
countryCodeISO3,
accessToken,
});
expect(result).toBeTruthy();
});

it('warning', async () => {
const events = [{ eventName: 'G5230', leadTime: '5-day' }];
await testFloodScenario(FloodsScenario.Warning, {
const result = await testFloodScenario(FloodsScenario.Warning, {
events,
countryCodeISO3,
accessToken,
});
expect(result).toBeTruthy();
});

it('warning-to-trigger', async () => {
const events = [{ eventName: 'G5220', leadTime: '4-day' }];
await testFloodScenario(FloodsScenario.WarningToTrigger, {
const result = await testFloodScenario(FloodsScenario.WarningToTrigger, {
events,
countryCodeISO3,
accessToken,
});
expect(result).toBeTruthy();
});

it('no-trigger', async () => {
const events = [];
await testFloodScenario(FloodsScenario.NoTrigger, {
const result = await testFloodScenario(FloodsScenario.NoTrigger, {
events,
countryCodeISO3,
accessToken,
});
expect(result).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface TestFloodScenarioDto {
export async function testFloodScenario(
scenario: FloodsScenario,
params: TestFloodScenarioDto,
): Promise<void> {
): Promise<boolean> {
const { events, countryCodeISO3, accessToken } = params;
const disasterType = DisasterType.Floods;
const disasterTypeLabel = disasters.find(
Expand Down Expand Up @@ -69,4 +69,6 @@ export async function testFloodScenario(
);
expect(hasEvent).toBe(true);
}

return true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ describe('Should send an email for eth malaria', () => {
});

it('trigger', async () => {
await testMalariaScenario(
const result = await testMalariaScenario(
EpidemicsScenario.Trigger,
countryCodeISO3,
accessToken,
);
expect(result).toBeTruthy();
});

it('no-trigger', async () => {
await testMalariaScenario(
const result = await testMalariaScenario(
EpidemicsScenario.NoTrigger,
countryCodeISO3,
accessToken,
);
expect(result).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function testMalariaScenario(
scenario: EpidemicsScenario,
countryCodeISO3: string,
accessToken: string,
): Promise<void> {
): Promise<boolean> {
const eventNames = ['0-month', '1-month', '2-month'];
const disasterTypeLabel = DisasterType.Malaria;

Expand Down Expand Up @@ -67,4 +67,6 @@ export async function testMalariaScenario(
expect(hasEvent).toBe(true);
}
}

return true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ describe('Should send an email for phl typhoon', () => {
});

it('trigger', async () => {
await testTyphoonScenario(
const result = await testTyphoonScenario(
TyphoonScenario.EventTrigger,
countryCodeISO3,
accessToken,
);
expect(result).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function testTyphoonScenario(
scenario: TyphoonScenario,
countryCodeISO3: string,
accessToken: string,
): Promise<void> {
): Promise<boolean> {
const nrOfEvents = 1;
const eventName = 'Mock typhoon';
const disasterTypeLabel = DisasterType.Typhoon;
Expand Down Expand Up @@ -55,4 +55,6 @@ export async function testTyphoonScenario(
const hasEvent = eventNameInEmail.includes(eventTitle);
expect(hasEvent).toBe(true);
}

return true;
}

0 comments on commit 5425539

Please sign in to comment.