@codecademy/gamut-tests
Version:
Shared component test setup for Gamut applications
34 lines (31 loc) • 1.17 kB
JavaScript
import { GamutProvider, theme } from '@codecademy/gamut-styles';
import { setupEnzyme as setupEnzymeBase, setupRtl as setupRtlBase } from 'component-test-setup';
import overArgs from 'lodash/overArgs';
import * as React from 'react';
// See https://www.notion.so/codecademy/Frontend-Unit-Tests-1cbf4e078a6647559b4583dfb6d3cb18 for more info
import { jsx as _jsx } from "react/jsx-runtime";
export const MockGamutProvider = _ref => {
let {
children
} = _ref;
return /*#__PURE__*/_jsx(GamutProvider, {
theme: theme,
useCache: false,
useGlobals: false,
children: children
});
};
function withMockGamutProvider(WrappedComponent) {
const WithBoundaryComponent = props => /*#__PURE__*/_jsx(MockGamutProvider, {
children: /*#__PURE__*/_jsx(WrappedComponent, {
...props
})
});
return WithBoundaryComponent;
}
// overArgs isn't fully typed yet for lack of curried generics, so we have to cast it...
/**
* @deprecated Enzyme is no longer being maintained. Use RTL instead.
*/
export const setupEnzyme = overArgs(setupEnzymeBase, withMockGamutProvider);
export const setupRtl = overArgs(setupRtlBase, withMockGamutProvider);