angular-cn/aio/tests/deployment/unit/testServiceWorkerRoutes.spec.ts
Alex Rickabaugh be24f9f0cb feat(docs-infra): Convert AIO to use the new Service Worker 5.0.0. (#19795)
AIO is currently using a beta version of @angular/service-worker.
Since that was implemented, the SW has been rewritten and released
as part of Angular 5.0.0. This commit updates AIO to use the latest
implementation, with an appropriate configuration file that caches
the various AIO assets in useful ways.

PR Close #19795
2018-08-27 16:30:42 -04:00

41 lines
1.7 KiB
TypeScript

import { loadLegacyUrls, loadLocalSitemapUrls, loadSWRoutes } from '../shared/helpers';
// NOTE: The new `@angular/service-worker` does not support configurable routes.
xdescribe('service-worker routes', () => {
loadLocalSitemapUrls().forEach(url => {
it('should process URLs in the Sitemap', () => {
const routes = loadSWRoutes();
expect(routes.some(test => test(url))).toBeTruthy(url);
});
});
loadLegacyUrls().forEach(urlPair => {
const url = urlPair[0];
it('should ignore legacy URLs that will be redirected', () => {
const routes = loadSWRoutes();
expect(routes.some(test => test(url))).toBeFalsy(url);
});
});
it('should ignore stackblitz URLs', () => {
const routes = loadSWRoutes();
// Normal StackBlitz URLs.
expect(routes.some(test => test('/generated/live-examples/toh-pt6/stackblitz.html'))).toBeFalsy();
expect(routes.some(test => test('/generated/live-examples/toh-pt6/stackblitz'))).toBeFalsy();
// Embedded StackBlitz URLs.
expect(routes.some(test => test('/generated/live-examples/toh-pt6/stackblitz.html?ctl=1'))).toBeFalsy();
expect(routes.some(test => test('/generated/live-examples/toh-pt6/stackblitz?ctl=1'))).toBeFalsy();
});
it('should ignore URLs to files with extensions', () => {
const routes = loadSWRoutes();
expect(routes.some(test => test('/generated/zips/animations/animations.zip'))).toBeFalsy();
expect(routes.some(test => test('/generated/images/guide/animations/animation_auto.gif'))).toBeFalsy();
expect(routes.some(test => test('/generated/ie-polyfills.min.js'))).toBeFalsy();
expect(routes.some(test => test('/generated/docs/guide/animations.json'))).toBeFalsy();
});
});