test(platform-browser-dynamic): avoid swallowing error in `CachedResourceLoader` test (#30515)

Previously, in order to assert that the promise was not resolved, an
error was thrown when the promise was resolved successfully. At the
same, `.catch()` was used to silence the (expected) promise rejection.
However, the chained `.catch()` handler would also catch (and swallow)
the error thrown on resolving the promise, making the test pass, even if
the promise was not rejected.

This commit fixes it by ensuring that the error thrown on resolving the
promise is not caught by the rejection handler.

PR Close #30515
This commit is contained in:
George Kalpakas 2019-05-16 18:33:18 +03:00 committed by Jason Aden
parent 6bf8b1007c
commit 848e53efd0
1 changed files with 3 additions and 3 deletions

View File

@ -36,9 +36,9 @@ if (isBrowser) {
it('should reject the Promise on failure', async(() => {
resourceLoader = createCachedResourceLoader();
resourceLoader.get('unknown.html')
.then((text) => { throw new Error('Not expected to succeed.'); })
.catch((error) => {/** success */});
resourceLoader.get('unknown.html').then(() => {
throw new Error('Not expected to succeed.');
}, () => {/* success */});
}));
it('should allow fakeAsync Tests to load components with templateUrl synchronously',