Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// npx vitest src/components/settings/__tests__/TemperatureControl.spec.tsx

import { render, screen, fireEvent } from "@testing-library/react"
import { render, screen, fireEvent, waitFor } from "@testing-library/react"

import { TemperatureControl } from "../TemperatureControl"

Expand Down Expand Up @@ -64,16 +64,18 @@ describe("TemperatureControl", () => {
// Uncheck - should clear temperature.
fireEvent.click(checkbox)

// Waiting for debounce.
await new Promise((x) => setTimeout(x, 100))
expect(onChange).toHaveBeenCalledWith(null)
// Wait for debounced onChange call.
await waitFor(() => {
expect(onChange).toHaveBeenCalledWith(null)
})

// Check - should restore previous temperature.
fireEvent.click(checkbox)

// Waiting for debounce.
await new Promise((x) => setTimeout(x, 100))
expect(onChange).toHaveBeenCalledWith(0.7)
// Wait for debounced onChange call.
await waitFor(() => {
expect(onChange).toHaveBeenCalledWith(0.7)
})
})

it("syncs checkbox state when value prop changes", () => {
Expand Down
Loading