Skip to content

Commit 7b3ada5

Browse files
Copilotk3nsei
andcommitted
Fix Vitest DOM matchers and TypeScript configuration for demo tests
Co-authored-by: k3nsei <190422+k3nsei@users.noreply.github.com>
1 parent 68e2a4d commit 7b3ada5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

projects/demo/src/app/app.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ describe('AppComponent', () => {
3838
const actual = spectator.query('header h1');
3939
const expected = 'ng-in-viewport demo';
4040

41-
expect(actual).toHaveText(expected);
41+
expect(actual?.textContent?.trim()).toBe(expected);
4242
});
4343
});

projects/demo/src/app/example/example.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('ExampleComponent', () => {
4949
component.handleAction({ target: el, visible: false } as InViewportAction);
5050
spectator.detectChanges();
5151

52-
expect(el).not.toHaveClass(activeClassName);
52+
expect(el?.classList.contains(activeClassName)).toBe(false);
5353
});
5454

5555
it('should be active item', () => {
@@ -58,7 +58,7 @@ describe('ExampleComponent', () => {
5858
component.handleAction({ target: el, visible: true } as InViewportAction);
5959
spectator.detectChanges();
6060

61-
expect(el).toHaveClass(activeClassName);
61+
expect(el?.classList.contains(activeClassName)).toBe(true);
6262
});
6363
});
6464

@@ -76,7 +76,7 @@ describe('ExampleComponent', () => {
7676
component.handleAction({ target: el, visible: false } as InViewportAction);
7777
spectator.detectChanges();
7878

79-
expect(el).not.toHaveClass(activeClassName);
79+
expect(el?.classList.contains(activeClassName)).toBe(false);
8080
});
8181

8282
it('should be active item', () => {
@@ -85,7 +85,7 @@ describe('ExampleComponent', () => {
8585
component.handleAction({ target: el, visible: true } as InViewportAction);
8686
spectator.detectChanges();
8787

88-
expect(el).toHaveClass(activeClassName);
88+
expect(el?.classList.contains(activeClassName)).toBe(true);
8989
});
9090
});
9191
});

0 commit comments

Comments
 (0)