Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/components/__tests__/ThemeController.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const { mockGetColorAsync, mockDestroy } = vi.hoisted(() => ({
// The hook uses fast-average-color, which we need to mock so it doesn't try to fetch real images in tests.
vi.mock("fast-average-color", () => {
return {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
FastAverageColor: vi.fn().mockImplementation(function(this: any) {
FastAverageColor: vi.fn().mockImplementation(function(this: { getColorAsync: unknown; destroy: unknown }) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When mocking FastAverageColor, ensure that the test suite includes cases for failure scenarios, such as a rejected promise from getColorAsync. This is necessary to verify that the application's error handling logic functions correctly and that fallback colors are maintained, as per repository rules for asynchronous color operations.

References
  1. Ensure that asynchronous operations (e.g., color extraction from images) have test cases covering failure scenarios (e.g., rejected promises) to verify that error handling logic works correctly and fallback values are preserved.

this.getColorAsync = mockGetColorAsync;
this.destroy = mockDestroy;
return this;
Expand Down Expand Up @@ -44,8 +43,7 @@ describe("ThemeController", () => {
value: [100, 150, 200, 255]
});
// Ensure adjustAccentColor mock implementation is restored
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(colorLib.adjustAccentColor as any).mockImplementation((color: any) => ({
vi.mocked(colorLib.adjustAccentColor).mockImplementation((color) => ({
accent: `mock-accent-${color}`,
accentRgb: `mock-rgb-${color}`,
accentHover: `mock-hover-${color}`,
Expand Down
Loading