{
});
it(`Highlight is shown`, () => {
- const element = document.querySelector(`#ica`)?.firstElementChild as HTMLElement;
+ const element = document
+ .querySelector(`#ica`)
+ ?.querySelector(`tui-highlight`) as HTMLElement | null;
- expect(element.style.display).toBe(`block`);
+ expect(element).toBeTruthy();
});
it(`Highlight is not shown`, () => {
- const element = document.querySelector(`#dong`)?.firstElementChild as HTMLElement;
+ const element = document
+ .querySelector(`#dong`)
+ ?.querySelector(`tui-highlight`) as HTMLElement | null;
- expect(element.style.display).toBe(`none`);
+ expect(element).toBeFalsy();
});
it(`Highlight color is yellow`, () => {
- const element = document.querySelector(`#aaa`)?.firstElementChild as HTMLElement;
+ const element = document.querySelector(`#aaa`) as HTMLElement;
- expect(element.style.background).toBe(`yellow`);
+ expect(element.style.getPropertyValue(`--tui-highlight-color`)).toBe(`yellow`);
+ });
+});
+
+describe(`TuiHighlight directive in multi occurrence mode`, () => {
+ @Component({
+ template: `
+
+ HAPICA HAPICA HAPICA
+
+ `,
+ })
+ class TestComponent {}
+
+ configureTestSuite(() => {
+ TestBed.configureTestingModule({
+ imports: [TuiHighlightModule],
+ declarations: [TestComponent],
+ });
+ });
+
+ beforeEach(() => {
+ const fixture = TestBed.createComponent(TestComponent);
+
+ fixture.detectChanges();
+ });
+
+ it(`Highlights is shown`, () => {
+ const elements = Array.from(
+ document
+ .querySelector(`#ica`)
+ ?.querySelectorAll(`tui-highlight`) as ArrayLike
,
+ );
+
+ expect(elements.length).toBe(3);
+ });
+});
+
+describe(`TuiHighlight directive in case sensitive mode`, () => {
+ @Component({
+ template: `
+
+ HAPICA
+
+
+ HAPICA
+
+ `,
+ })
+ class TestComponent {}
+
+ configureTestSuite(() => {
+ TestBed.configureTestingModule({
+ imports: [TuiHighlightModule],
+ declarations: [TestComponent],
+ });
+ });
+
+ beforeEach(() => {
+ const fixture = TestBed.createComponent(TestComponent);
+
+ fixture.detectChanges();
+ });
+
+ it(`Highlights is not shown`, () => {
+ const elements = Array.from(
+ document
+ .querySelector(`#f`)
+ ?.querySelectorAll(`tui-highlight`) as ArrayLike,
+ );
+
+ expect(elements.length).toBe(0);
+ });
+
+ it(`Highlights is shown`, () => {
+ const elements = Array.from(
+ document
+ .querySelector(`#s`)
+ ?.querySelectorAll(`tui-highlight`) as ArrayLike,
+ );
+
+ expect(elements.length).toBe(1);
});
});