Skip to content

Commit e0da670

Browse files
Forgotten coverage on unknown component
1 parent 6e53364 commit e0da670

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

src/app/shared/error-handler/error-views/unknown-error/unknown-error.component.spec.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ import { TranslateModule, TranslateService } from '@ngx-translate/core';
44

55
import { UnknownErrorComponent } from './unknown-error.component';
66

7+
vi.mock('@lottiefiles/dotlottie-web', () => {
8+
return {
9+
DotLottie: vi.fn().mockImplementation(function() {
10+
let readyCallback: (() => void) | undefined;
11+
12+
return {
13+
addEventListener: vi.fn((event: string, callback: () => void): void => {
14+
if (event === 'ready') {
15+
readyCallback = callback;
16+
}
17+
}),
18+
19+
uiTriggerReady: (): void => {
20+
if (readyCallback) {
21+
readyCallback();
22+
}
23+
},
24+
destroy: vi.fn(),
25+
};
26+
}),
27+
};
28+
});
29+
730
describe('UnknownErrorComponent', () => {
831

932
let component: UnknownErrorComponent;
@@ -97,4 +120,22 @@ describe('UnknownErrorComponent', () => {
97120
expect(subtitle.textContent.trim()).toBe('It seems this page took a leap through spacetime...');
98121
});
99122
});
123+
124+
describe('Animation Lifecycle', () => {
125+
it('should set isReady to true when animation is ready', () => {
126+
// --- ARRANGE ---
127+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
128+
const lottieInstance = (component as any).dotLottieInstance;
129+
130+
// --- ACT ---
131+
lottieInstance.uiTriggerReady();
132+
fixture.detectChanges();
133+
134+
// --- ASSERT ---
135+
expect(component.isReady).toBe(true);
136+
137+
const section = fixture.debugElement.query(By.css('.unknown-error')).nativeElement;
138+
expect(section.classList.contains('is-ready')).toBe(true);
139+
});
140+
});
100141
});

0 commit comments

Comments
 (0)