/** * @license * Copyright Google Inc. 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 {Component} from '@angular/core'; import {TestBed} from '@angular/core/testing'; import {of } from 'rxjs'; describe('text instructions', () => { it('should handle all flavors of interpolated text', () => { @Component({ template: `
{{who | async}} sells {{(item | async)?.what}} down by the {{(item | async)?.where}}.
` }) class App { who = of ('Sally'); item = of ({ what: 'seashells', where: 'seashore', }); } TestBed.configureTestingModule({declarations: [App]}); const fixture = TestBed.createComponent(App); fixture.detectChanges(); const p = fixture.nativeElement.querySelector('p') as HTMLDivElement; expect(p.textContent).toBe('Sally sells seashells down by the seashore.'); }); it('should not sanitize urls in interpolated text', () => { @Component({ template: '{{thisisfine}}
', }) class App { thisisfine = 'javascript:alert("image_of_dog_with_coffee_in_burning_building.gif")'; } TestBed.configureTestingModule({declarations: [App]}); const fixture = TestBed.createComponent(App); fixture.detectChanges(); const p = fixture.nativeElement.querySelector('p'); expect(p.textContent) .toBe('javascript:alert("image_of_dog_with_coffee_in_burning_building.gif")'); }); it('should not allow writing HTML in interpolated text', () => { @Component({ template: '