Skip to content

Commit

Permalink
test(core): fix test with false-negative risk (#54025)
Browse files Browse the repository at this point in the history
change assertion to handle the case where the function doesn't throw

PR Close #54025
  • Loading branch information
yjaaidi authored and pkozlowski-opensource committed Jan 23, 2024
1 parent 9778326 commit 5f9cac0
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/core/test/application_init_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ describe('ApplicationInitStatus', () => {
});

expect(status.done).toBe(false);

try {
await status.donePromise;
fail('donePromise should have been rejected when observable emits an error');
Expand All @@ -174,15 +175,13 @@ describe('ApplicationInitStatus', () => {
});

it('should throw', () => {
try {
TestBed.inject(ApplicationInitStatus);
} catch (e: any) {
expect(e.message).toBe(
'NG0209: Unexpected type of the `APP_INITIALIZER` token value ' +
`(expected an array, but got string). ` +
'Please check that the `APP_INITIALIZER` token is configured as a ' +
'`multi: true` provider. Find more at https://angular.io/errors/NG0209');
}
expect(() => TestBed.inject(ApplicationInitStatus))
.toThrowError(
'NG0209: Unexpected type of the `APP_INITIALIZER` token value ' +
`(expected an array, but got string). ` +
'Please check that the `APP_INITIALIZER` token is configured as a ' +
'`multi: true` provider. Find more at https://angular.io/errors/NG0209',
);
});
});
});

0 comments on commit 5f9cac0

Please sign in to comment.