2 import {HighlightPipe} from "./highlight-filter.pipe";
3 import {TestBed} from "@angular/core/testing";
5 describe('Highlight Pipe', () => {
6 let highlightPipe: HighlightPipe;
8 beforeAll(done => (async () => {
9 TestBed.configureTestingModule({});
10 await TestBed.compileComponents();
12 highlightPipe = new HighlightPipe();
14 })().then(done).catch(done.fail));
16 test('Highlight Pipe should be defined', () => {
17 expect(highlightPipe).toBeDefined();
20 test('Highlight Pipe should return "HTML" with highlight class if match exist', () => {
21 let result : string = highlightPipe.transform('Hello World', 'Wor');
22 expect(result).toEqual('Hello <span class="highlight">Wor</span>ld');
25 test('Highlight Pipe should not return "HTML" with highlight class if no match exist', () => {
26 let result : string = highlightPipe.transform('Hello World', 'ABC');
27 expect(result).toEqual('Hello World');