blob: 73f8e55ede2bacfd38656fb9b67e18412a5db456 (
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
30
31
32
33
34
35
36
37
38
39
40
41
|
import { TestBed } from '@angular/core/testing';
import { configureTestBed } from '~/testing/unit-test-helper';
import { SearchHighlightPipe } from './search-highlight.pipe';
describe('SearchHighlightPipe', () => {
let pipe: SearchHighlightPipe;
configureTestBed({
providers: [SearchHighlightPipe]
});
beforeEach(() => {
pipe = TestBed.inject(SearchHighlightPipe);
});
it('create an instance', () => {
expect(pipe).toBeTruthy();
});
it('transforms with a matching keyword ', () => {
const value = 'overall HEALTH_WARN Dashboard debug mode is enabled';
const args = 'Dashboard';
const expected = 'overall HEALTH_WARN <mark>Dashboard</mark> debug mode is enabled';
expect(pipe.transform(value, args)).toEqual(expected);
});
it('transforms with a matching keyword having regex character', () => {
const value = 'loreum ipsum .? dolor sit amet';
const args = '.?';
const expected = 'loreum ipsum <mark>.?</mark> dolor sit amet';
expect(pipe.transform(value, args)).toEqual(expected);
});
it('transforms with empty search keyword', () => {
const value = 'overall HEALTH_WARN Dashboard debug mode is enabled';
expect(pipe.transform(value, '')).toBe(value);
});
});
|