You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
filepizza/tests/unit/useRotatingSpinner.test.ts

22 lines
612 B
TypeScript

import { describe, it, expect, vi } from 'vitest'
import {
setRotating,
addRotationListener,
removeRotationListener,
getRotating,
} from '../../src/hooks/useRotatingSpinner'
describe('useRotatingSpinner state helpers', () => {
it('notifies listeners on state change', () => {
const listener = vi.fn()
addRotationListener(listener)
setRotating(true)
expect(listener).toHaveBeenCalledWith(true)
expect(getRotating()).toBe(true)
setRotating(false)
expect(listener).toHaveBeenCalledWith(false)
expect(getRotating()).toBe(false)
removeRotationListener(listener)
})
})