2018-05-24 08:06:53 -04:00
|
|
|
import { getSwNavigationUrlChecker, loadLegacyUrls, loadLocalSitemapUrls } from '../shared/helpers';
|
2018-01-25 15:19:32 -05:00
|
|
|
|
2018-05-24 08:06:53 -04:00
|
|
|
describe('ServiceWorker navigation URLs', () => {
|
|
|
|
const isNavigationUrl = getSwNavigationUrlChecker();
|
2018-01-25 15:19:32 -05:00
|
|
|
|
2018-02-27 18:24:07 -05:00
|
|
|
loadLocalSitemapUrls().forEach(url => {
|
2018-05-24 08:06:53 -04:00
|
|
|
it('should treat URLs in the Sitemap as navigation URLs', () => {
|
|
|
|
expect(isNavigationUrl(url)).toBeTruthy(url);
|
2018-01-25 15:19:32 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
loadLegacyUrls().forEach(urlPair => {
|
|
|
|
const url = urlPair[0];
|
2018-05-24 08:06:53 -04:00
|
|
|
it('should treat legacy URLs that will be redirected as non-navigation URLs', () => {
|
|
|
|
expect(isNavigationUrl(url)).toBeFalsy(url);
|
2018-01-25 15:19:32 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-05-24 08:06:53 -04:00
|
|
|
it('should treat StackBlitz URLs as non-navigation URLs', () => {
|
|
|
|
expect(isNavigationUrl('/generated/live-examples/toh-pt6/stackblitz.html')).toBeFalsy();
|
|
|
|
expect(isNavigationUrl('/generated/live-examples/toh-pt6/stackblitz')).toBeFalsy();
|
|
|
|
});
|
2018-05-01 16:54:03 -04:00
|
|
|
|
2018-05-24 08:06:53 -04:00
|
|
|
it('should treat URLs to files with extensions as non-navigation URLs', () => {
|
|
|
|
expect(isNavigationUrl('/generated/zips/animations/animations.zip')).toBeFalsy();
|
|
|
|
expect(isNavigationUrl('/generated/images/guide/animations/animation_auto.gif')).toBeFalsy();
|
2019-04-24 08:27:23 -04:00
|
|
|
expect(isNavigationUrl('/generated/ngsw-worker.js')).toBeFalsy();
|
2018-05-24 08:06:53 -04:00
|
|
|
expect(isNavigationUrl('/generated/docs/guide/animations.json')).toBeFalsy();
|
2018-01-25 15:19:32 -05:00
|
|
|
});
|
|
|
|
|
2018-05-24 08:06:53 -04:00
|
|
|
it('should treat `/docs*` URLs correctly', () => {
|
|
|
|
const navigationUrls = ['/docs', '/docs/'];
|
|
|
|
const nonNavigationUrls = ['/docs/foo', '/docs/foo/', '/docs/foo/bar'];
|
|
|
|
|
|
|
|
navigationUrls.forEach(url => expect(isNavigationUrl(url)).toBeTruthy(url));
|
|
|
|
nonNavigationUrls.forEach(url => expect(isNavigationUrl(url)).toBeFalsy(url));
|
2018-01-25 15:19:32 -05:00
|
|
|
});
|
|
|
|
});
|