test(docs-infra): make it easier to identify the failing URL in `testFirebaseRedirection.spec.ts` (#41842)

This commit includes the URL under test in the test description in
`testFirebaseRedirection.spec.ts` to make it easier to identify the
affected URL when a test fails.

It also avoids unnecessarily creating multiple `FirebaseRedirector`
instances by sharing instances between tests.

PR Close #41842
This commit is contained in:
George Kalpakas 2021-04-27 22:50:12 +03:00 committed by Jessica Janiuk
parent d1f5a9e44b
commit 1aee5a79c6
1 changed files with 11 additions and 6 deletions

View File

@ -2,20 +2,25 @@ import { getRedirector, loadLegacyUrls, loadLocalSitemapUrls, loadRedirects } fr
describe('firebase.json redirect config', () => {
describe('with sitemap urls', () => {
const redirector = getRedirector();
loadLocalSitemapUrls().forEach(url => {
it('should not redirect any urls in the sitemap', () => {
expect(getRedirector().redirect(url)).toEqual(url);
it(`should not redirect sitemap URL '${url}'`, () => {
expect(redirector.redirect(url)).toEqual(url);
});
});
});
describe('with legacy urls', () => {
const redirector = getRedirector();
loadLegacyUrls().forEach(urlPair => {
it('should redirect the legacy urls', () => {
const redirector = getRedirector();
expect(redirector.redirect(urlPair[0])).not.toEqual(urlPair[0]);
it(`should redirect legacy URL '${urlPair[0]}'`, () => {
const redirected = redirector.redirect(urlPair[0]);
expect(redirected).not.toEqual(urlPair[0]);
if (urlPair[1]) {
expect(redirector.redirect(urlPair[0])).toEqual(urlPair[1]);
expect(redirected).toEqual(urlPair[1]);
}
});
});