test(platform-server): don't set document to undefined for ivy tests (#27268)

PR Close #27268
This commit is contained in:
Olivier Combe 2018-11-21 16:50:35 +01:00 committed by Jason Aden
parent 2fce701ced
commit b09e03b28d

View File

@ -20,6 +20,7 @@ import {BEFORE_APP_SERIALIZED, INITIAL_CONFIG, PlatformState, ServerModule, Serv
import {fixmeIvy} from '@angular/private/testing'; import {fixmeIvy} from '@angular/private/testing';
import {Observable} from 'rxjs'; import {Observable} from 'rxjs';
import {first} from 'rxjs/operators'; import {first} from 'rxjs/operators';
import {ivyEnabled} from '../../core/src/ivy_switch';
@Component({selector: 'app', template: `Works!`}) @Component({selector: 'app', template: `Works!`})
class MyServerApp { class MyServerApp {
@ -534,8 +535,12 @@ class HiddenModule {
// PlatformConfig takes in a parsed document so that it can be cached across requests. // PlatformConfig takes in a parsed document so that it can be cached across requests.
doc = '<html><head></head><body><app></app></body></html>'; doc = '<html><head></head><body><app></app></body></html>';
called = false; called = false;
(global as any)['window'] = undefined; // We use `window` and `document` directly in some parts of render3 for ivy
(global as any)['document'] = undefined; // Only set it to undefined for legacy
if (!ivyEnabled) {
(global as any)['window'] = undefined;
(global as any)['document'] = undefined;
}
}); });
afterEach(() => { expect(called).toBe(true); }); afterEach(() => { expect(called).toBe(true); });
@ -632,19 +637,18 @@ class HiddenModule {
}); });
})); }));
fixmeIvy('to investigate') && it('should work with sanitizer to handle "innerHTML"', async(() => {
it('should work with sanitizer to handle "innerHTML"', async(() => { // Clear out any global states. These should be set when platform-server
// Clear out any global states. These should be set when platform-server // is initialized.
// is initialized. (global as any).Node = undefined;
(global as any).Node = undefined; (global as any).Document = undefined;
(global as any).Document = undefined; renderModule(HTMLTypesModule, {document: doc}).then(output => {
renderModule(HTMLTypesModule, {document: doc}).then(output => { expect(output).toBe(
expect(output).toBe( '<html><head></head><body><app ng-version="0.0.0-PLACEHOLDER">' +
'<html><head></head><body><app ng-version="0.0.0-PLACEHOLDER">' + '<div><b>foo</b> bar</div></app></body></html>');
'<div><b>foo</b> bar</div></app></body></html>'); called = true;
called = true; });
}); }));
}));
it('should handle element property "hidden"', async(() => { it('should handle element property "hidden"', async(() => {
renderModule(HiddenModule, {document: doc}).then(output => { renderModule(HiddenModule, {document: doc}).then(output => {