forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
http-transferstate-lazy-on-init-spec.ts
44 lines (36 loc) · 1.49 KB
/
http-transferstate-lazy-on-init-spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {browser, by, element} from 'protractor';
import {bootstrapClientApp, navigateTo, verifyNoBrowserErrors} from './util';
describe('Http TransferState Lazy On Init', () => {
beforeEach(async () => {
// Don't wait for Angular since it is not bootstrapped automatically.
await browser.waitForAngularEnabled(false);
// Load the page without waiting for Angular since it is not bootstrapped automatically.
await navigateTo('http-transferstate-lazy-on-init');
});
afterEach(async () => {
// Make sure there were no client side errors.
await verifyNoBrowserErrors();
});
it('should transfer http state in lazy component', async () => {
// Test the contents from the server.
expect(await element(by.css('div.one')).getText()).toBe('API 1 response');
// Bootstrap the client side app and retest the contents
await bootstrapClientApp();
expect(await element(by.css('div.one')).getText()).toBe('API 1 response');
// Validate that there were no HTTP calls to '/api'.
const requests = await browser.executeScript(() => {
return performance.getEntriesByType('resource');
});
const apiRequests = (requests as {name: string}[])
.filter(({name}) => name.includes('/api'))
.map(({name}) => name);
expect(apiRequests).toEqual([]);
});
});