Skip to content

Commit 39c6338

Browse files
committed
test: add test case
1 parent e129cb4 commit 39c6338

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/genStyleUtils.test.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,44 @@ describe('genStyleUtils', () => {
139139

140140
expect(document.head.innerHTML).toContain('@layer parent,test;');
141141
});
142+
143+
describe('disabledRuntimeStyle', () => {
144+
it('should work', () => {
145+
const usePrefix = jest.fn().mockReturnValue({
146+
rootPrefixCls: 'ant',
147+
iconPrefixCls: 'anticon',
148+
});
149+
150+
const config = {
151+
...mockConfig,
152+
useToken: jest.fn().mockReturnValue({
153+
theme: {},
154+
realToken: {},
155+
hashId: 'hash',
156+
token: {},
157+
cssVar: {},
158+
disabledRuntimeStyle: true,
159+
}),
160+
usePrefix,
161+
}
162+
const { genComponentStyleHook: gen } = genStyleUtils<
163+
TestCompTokenMap,
164+
object,
165+
object
166+
>(config);
167+
168+
const styleFn = jest.fn();
169+
const getDefaultToken = jest.fn();
170+
const useStyle = gen('TestComponent', styleFn, getDefaultToken)
171+
172+
const TestComponent: React.FC<SubStyleComponentProps> = ({ prefixCls, rootCls }) => {
173+
useStyle(prefixCls, rootCls);
174+
return <div data-testid="test-component">Test</div>;
175+
};
176+
177+
const { getByTestId } = render(<TestComponent prefixCls="test-prefix" rootCls="test-root" />);
178+
expect(getByTestId('test-component')).toHaveTextContent('Test');
179+
expect(usePrefix).not.toHaveBeenCalled();
180+
})
181+
})
142182
});

0 commit comments

Comments
 (0)