UNPKG

spin-wheel

Version:

An easy to use, themeable component for randomising choices and prizes.

33 lines (21 loc) 705 B
import {Wheel} from '../src/wheel.js'; import {jest} from '@jest/globals'; export function createWheel(props) { const wheel = new Wheel(createContainer(), props); addBlankItems(wheel, props?.numberOfItems); return wheel; } function addBlankItems(wheel, numberOfItems) { if (!numberOfItems) return; const newItems = []; for (let i = 0; i < numberOfItems; i++) { newItems.push({}); } wheel.items = wheel.items.concat(newItems); } export function createContainer() { const container = document.createElement('div'); jest.spyOn(container, 'clientWidth', 'get').mockReturnValue(500); jest.spyOn(container, 'clientHeight', 'get').mockReturnValue(500); return container; }