-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: support internal props (#428)
* chore: support internal props * chore: more props
- Loading branch information
Showing
4 changed files
with
116 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as React from 'react'; | ||
import type { MenuProps } from '../Menu'; | ||
|
||
export interface PrivateContextProps { | ||
_internalRenderMenuItem?: MenuProps['_internalRenderMenuItem']; | ||
} | ||
|
||
const PrivateContext = React.createContext<PrivateContextProps>({}); | ||
|
||
export default PrivateContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* eslint-disable no-undef */ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import classnames from 'classnames'; | ||
import Menu, { MenuItem } from '../src'; | ||
|
||
describe('Private Props', () => { | ||
it('_internalRenderMenuItem', () => { | ||
const wrapper = mount( | ||
<Menu | ||
_internalRenderMenuItem={node => | ||
React.cloneElement(node, { | ||
className: classnames(node.props.className, 'inject-cls'), | ||
}) | ||
} | ||
> | ||
<MenuItem key="1">1</MenuItem> | ||
</Menu>, | ||
); | ||
|
||
console.log(wrapper.html()); | ||
|
||
expect(wrapper.exists('.inject-cls')).toBeTruthy(); | ||
}); | ||
}); | ||
/* eslint-enable */ |