I have a pipe that sanatises HTML as below:
import { Pipe, PipeTransform } from \'@angular/core\';
import { DomSanitizer } from \'@angular/platform-browser\';
@
just in case anyone would like to reuse the constructor of the Pipe, you can use the TestBed to acheive the same result :
let pipe: SafeHtmlPipe;
let sanitized: DomSanitizer
beforeEach(async() => {
TestBed.configureTestingModule({
providers: [DomSanitizer]
});
sanitized = TestBed.get(DomSanitizer);
pipe = new SafeHtmlPipe(sanitized);
});
it('create an instance', () => {
expect(pipe).toBeTruthy();
});