Test Utilities
TestProvider
This is SpacewebProvider with theme object which can run in jest environment.
import { TestProvider } from '@sprinklrjs/spaceweb/test-utils/test-provider';...test('onClick', () => {const onClick = jest.fn();const { getByTestId } = render(<TestProvider><Button onClick={onClick}>Hello</Button></TestProvider>);fireEvent.click(getByTestId('button'));expect(onClick).toHaveBeenCalled();});
getCSSByTestId
This utility let's you test calculated CSS properties.
import { TestProvider, getCSSByTestId } from '@sprinklrjs/spaceweb/test-utils/test-provider';...test('fullWidth', () => {render(<TestProvider><Button fullWidth>Hello</Button></TestProvider>);const buttonCss = getCSSByTestId('button');expect(buttonCss.width).toEqual(theme.width.full);});