summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/pipes/highlight/highlight-filter.pipe.spec.ts
blob: 6c2fc42d79bbbb0eec0bf4f920e41eb9bca1db82 (plain)
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
import {HighlightPipe} from "./highlight-filter.pipe";
import {TestBed} from "@angular/core/testing";

describe('Highlight Pipe', () => {
  let highlightPipe: HighlightPipe;

  beforeAll(done => (async () => {
    TestBed.configureTestingModule({});
    await TestBed.compileComponents();

    highlightPipe = new HighlightPipe();

  })().then(done).catch(done.fail));

  test('Highlight Pipe should be defined', () => {
    expect(highlightPipe).toBeDefined();
  });

  test('Highlight Pipe should return "HTML" with highlight class if match exist', () => {
    let result : string = highlightPipe.transform('Hello World', 'Wor');
    expect(result).toEqual('Hello <span class="highlight">Wor</span>ld');
  });

  test('Highlight Pipe should not return "HTML" with highlight class if no match exist', () => {
    let result : string = highlightPipe.transform('Hello World', 'ABC');
    expect(result).toEqual('Hello World');
  });
});