@@ -44,30 +44,30 @@ describe('NoticeBar', () => {
4444 expect ( component . props . style ) . toMatchObject ( { fontSize : 12 } ) ;
4545 } ) ;
4646
47- // it('onPress', () => {
48- // const fn = jest.fn();
49- // const { getByTestId } = render(<NoticeBar onPress={fn}>onPress</NoticeBar>);
50- // const component = getByTestId('RNE__NoticeBar__wrap');
51- // fireEvent(component, 'press');
52- // expect(fn).toHaveBeenCalled();
53- // });
47+ it ( 'textStyle' , ( ) => {
48+ const { UNSAFE_getByType } = render ( < NoticeBar textStyle = { { fontSize : 20 } } /> ) ;
49+ const component = UNSAFE_getByType ( Marquee ) ;
50+ expect ( component . props . style [ 1 ] . fontSize ) . toBe ( 20 ) ;
51+ } ) ;
52+
53+ it ( 'onPress events' , ( ) => {
54+ const fn = jest . fn ( ) ;
55+ const { getByTestId } = render ( < NoticeBar mode = "link" onPress = { fn } > onPress</ NoticeBar > ) ;
56+ const component = getByTestId ( 'RNE__NoticeBar__link' ) ;
57+ fireEvent ( component , 'press' ) ;
58+ expect ( fn ) . toHaveBeenCalled ( ) ;
59+ } ) ;
5460
55- // it('action', () => {
56- // const { getByText } = render(<NoticeBar action={<Text>去看看</Text>} />);
57- // expect(getByText('去看看')).toBeTruthy();
58- // });
61+ it ( 'action' , ( ) => {
62+ const { getByText } = render ( < NoticeBar mode = "closable" action = { < Text > 去看看</ Text > } /> ) ;
63+ expect ( getByText ( '去看看' ) ) . toBeTruthy ( ) ;
64+ } ) ;
5965
60- // it('style', () => {
61- // const { getByTestId } = render(<NoticeBar style={{ height: 50 }} />);
62- // const component = getByTestId('RNE__NoticeBar__wrap ');
63- // const styles = toObject(component.props.style);
64- // expect(styles.height).toBe(50);
65- // });
66+ it ( 'style' , ( ) => {
67+ const { getByTestId } = render ( < NoticeBar mode = "closable" style = { { height : 50 } } /> ) ;
68+ const component = getByTestId ( 'RNE__NoticeBar__style ' ) ;
69+ const styles = toObject ( component . props . style ) ;
70+ expect ( styles . height ) . toBe ( 50 ) ;
71+ } ) ;
6672
67- // it('textStyle', () => {
68- // const { getByTestId } = render(<NoticeBar textStyle={{ fontSize: 20 }} />);
69- // const component = getByTestId('RNE__NoticeBar__div');
70- // const styles = toObject(component.props.style);
71- // expect(styles.fontSize).toBe(20);
72- // });
7373} ) ;
0 commit comments