angular-cn/aio/tests/deployment/testFirebaseRedirection.spe...

32 lines
997 B
TypeScript
Raw Normal View History

import { getRedirector, loadLegacyUrls, loadRedirects, loadSitemapUrls } from './helpers';
describe('firebase.json redirect config', () => {
describe('with sitemap urls', () => {
loadSitemapUrls().forEach(url => {
it('should not redirect any urls in the sitemap', () => {
expect(getRedirector().redirect(url)).toEqual(url);
});
});
});
describe('with legacy urls', () => {
loadLegacyUrls().forEach(urlPair => {
it('should redirect the legacy urls', () => {
const redirector = getRedirector();
expect(redirector.redirect(urlPair[0])).not.toEqual(urlPair[0]);
if (urlPair[1]) {
expect(redirector.redirect(urlPair[0])).toEqual(urlPair[1]);
}
});
});
describe('destinations', () => {
loadRedirects().forEach(redirect => {
it('should match pattern "^(https?:/)?/.*"', () => {
expect(redirect.destination).toMatch(/^(https?:\/)?\/.*/);
});
});
});
});
});