-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
246 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
src/app/components/dashboard/reward-chart/reward-chart.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/app/components/dashboard/success-fail-view/success-fail-view.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/app/components/full-page-loading/full-page-loading.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/// <reference types="vitest" /> | ||
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing' | ||
import { FullPageLoadingComponent } from './full-page-loading.component' | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations' | ||
|
||
describe('FullPageLoadingComponent', () => { | ||
let component: FullPageLoadingComponent | ||
let fixture: ComponentFixture<FullPageLoadingComponent> | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [FullPageLoadingComponent, NoopAnimationsModule], | ||
}).compileComponents() | ||
|
||
fixture = TestBed.createComponent(FullPageLoadingComponent) | ||
component = fixture.componentInstance | ||
}) | ||
|
||
it('should not show loading immediately when loading is true and then show it after SKIP_LOADING_IF_FASTER_THAN ms', fakeAsync(() => { | ||
// Instead of calling fixture.detectChanges(), call ngOnChanges() manually | ||
component.loading = true | ||
component.ngOnChanges() // simulate the one-time change | ||
|
||
// Immediately after, reset() was called so showLoading remains false. | ||
expect(component.showLoading).toBe(false) | ||
|
||
// Advance time past SKIP_LOADING_IF_FASTER_THAN (here using 35ms as a buffer). | ||
tick(35) | ||
// The setTimeout callback should now have run and, since loading is still true, | ||
// set showLoading to true (it also calls cdr.detectChanges(), so we don't trigger extra change detection). | ||
expect(component.showLoading).toBe(true) | ||
})) | ||
|
||
it('should skip showing the loading screen if loading becomes false quickly', fakeAsync(() => { | ||
// Start with loading true and call ngOnChanges once. | ||
component.loading = true | ||
component.ngOnChanges() | ||
tick(20) | ||
|
||
// Now simulate that loading becomes false quickly. | ||
component.loading = false | ||
// Call ngOnChanges again to simulate the input change. | ||
component.ngOnChanges() | ||
|
||
// Advance time to flush the pending timeout. | ||
tick(31) | ||
// In the "else" branch of ngOnChanges, loadingDoneStartPreRender() is called, | ||
// which sets showContent to true and ensures showLoading stays false. | ||
expect(component.showLoading).toBe(false) | ||
expect(component.showContent).toBe(true) | ||
|
||
// Because the real animation callbacks aren’t triggered in test mode (using NoopAnimationsModule), | ||
// manually simulate the animation finish. | ||
component.onLoadingAnimationDone() | ||
tick(component.renderWait) | ||
expect(component.fadeInComplete).toBe('done') | ||
})) | ||
|
||
it('should emit fadeInCompleted event after loading animation is done', fakeAsync(() => { | ||
const fadeInSpy = vi.spyOn(component.fadeInCompleted, 'emit') | ||
|
||
// For immediate loading completion, set loading to false and call ngOnChanges. | ||
component.loading = false | ||
component.ngOnChanges() | ||
|
||
tick(31) | ||
// Manually simulate the animation callback. | ||
component.onLoadingAnimationDone() | ||
tick(component.renderWait) | ||
|
||
expect(fadeInSpy).toHaveBeenCalled() | ||
})) | ||
|
||
it('should reset the component state when reset() is called', () => { | ||
// Set some non-default state. | ||
component.showContent = true | ||
component.fadeInComplete = 'done' | ||
component.showLoading = true | ||
|
||
// Call reset(). | ||
component.reset() | ||
|
||
// Verify that state is reset to its initial values. | ||
expect(component.showContent).toBe(false) | ||
expect(component.fadeInComplete).toBe('wait') | ||
expect(component.showLoading).toBe(false) | ||
}) | ||
|
||
it('onLoadingAnimationStart should mark that loading animation has started', () => { | ||
component.onLoadingAnimationStart() | ||
const loadingAnimationStarted = (component as any).loadingAnimationStarted | ||
expect(loadingAnimationStarted).toBe(true) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 14 additions & 14 deletions
28
src/app/modals/dashboard-and-group-select/dashboard-and-group-select.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.