feat(chart): add series styling and visibility controls
This commit is contained in:
@@ -8,6 +8,8 @@ interface ResizeObserverEntryMock {
|
||||
type ResizeCallback = (entries: ResizeObserverEntryMock[]) => void
|
||||
|
||||
export const resizeObservers: ResizeObserverMock[] = []
|
||||
const animationFrameCallbacks = new Map<number, FrameRequestCallback>()
|
||||
let animationFrameId = 0
|
||||
|
||||
export class ResizeObserverMock {
|
||||
private target?: Element
|
||||
@@ -35,6 +37,20 @@ export class ResizeObserverMock {
|
||||
}
|
||||
|
||||
vi.stubGlobal('ResizeObserver', ResizeObserverMock)
|
||||
vi.stubGlobal(
|
||||
'requestAnimationFrame',
|
||||
vi.fn((callback: FrameRequestCallback) => {
|
||||
animationFrameId += 1
|
||||
animationFrameCallbacks.set(animationFrameId, callback)
|
||||
return animationFrameId
|
||||
}),
|
||||
)
|
||||
vi.stubGlobal(
|
||||
'cancelAnimationFrame',
|
||||
vi.fn((id: number) => {
|
||||
animationFrameCallbacks.delete(id)
|
||||
}),
|
||||
)
|
||||
vi.stubGlobal(
|
||||
'matchMedia',
|
||||
vi.fn((query: string): MediaQueryList => ({
|
||||
@@ -51,4 +67,16 @@ vi.stubGlobal(
|
||||
|
||||
beforeEach(() => {
|
||||
resizeObservers.length = 0
|
||||
animationFrameCallbacks.clear()
|
||||
animationFrameId = 0
|
||||
})
|
||||
|
||||
export function flushAnimationFrames(timestamp = 0) {
|
||||
const callbacks = Array.from(animationFrameCallbacks.values())
|
||||
animationFrameCallbacks.clear()
|
||||
callbacks.forEach((callback) => callback(timestamp))
|
||||
}
|
||||
|
||||
export function pendingAnimationFrameCount(): number {
|
||||
return animationFrameCallbacks.size
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user