-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
components/notice-bar/__tests__/__snapshots__/index.test.js.snap
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,75 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`NoticeBar renders correctly 1`] = ` | ||
<View | ||
accessibilityComponentType={undefined} | ||
accessibilityLabel={undefined} | ||
accessibilityTraits={undefined} | ||
accessible={true} | ||
hitSlop={undefined} | ||
onLayout={undefined} | ||
onResponderGrant={[Function]} | ||
onResponderMove={[Function]} | ||
onResponderRelease={[Function]} | ||
onResponderTerminate={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
style={ | ||
Array [ | ||
Object { | ||
"alignItems": "center", | ||
"backgroundColor": "#fffada", | ||
"flexDirection": "row", | ||
"height": 36, | ||
"overflow": "hidden", | ||
}, | ||
undefined, | ||
] | ||
} | ||
testID={undefined} | ||
> | ||
<View | ||
style={ | ||
Array [ | ||
Object { | ||
"marginLeft": 15, | ||
}, | ||
] | ||
} | ||
> | ||
<Image | ||
source={ | ||
Object { | ||
"uri": "https://zos.alipayobjects.com/rmsportal/UgviADRsIpznkjSEXWEaPTlKtPCMSlth.png", | ||
} | ||
} | ||
style={ | ||
Object { | ||
"height": 12, | ||
"width": 14, | ||
} | ||
} | ||
/> | ||
</View> | ||
<Text | ||
accessible={true} | ||
allowFontScaling={true} | ||
ellipsizeMode="tail" | ||
style={ | ||
Array [ | ||
Object { | ||
"color": "#f4333c", | ||
"flex": 1, | ||
"fontSize": 15, | ||
"marginRight": 15, | ||
}, | ||
Object { | ||
"marginLeft": 5, | ||
}, | ||
] | ||
} | ||
> | ||
Notice: The arrival time of incomes and transfers of Yu 'E Bao will be delayed during National Day. | ||
</Text> | ||
</View> | ||
`; |
39 changes: 39 additions & 0 deletions
39
components/notice-bar/__tests__/__snapshots__/index.test.web.js.snap
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,39 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`NoticeBar renders correctly 1`] = ` | ||
<div | ||
class="am-notice-bar" | ||
role="alert" | ||
> | ||
<div | ||
aria-hidden="true" | ||
class="am-notice-bar-icon" | ||
> | ||
<svg | ||
class="am-icon am-icon-[object Object] am-icon-xxs" | ||
> | ||
<use | ||
xlink:href="#[object Object]" | ||
/> | ||
</svg> | ||
</div> | ||
<div | ||
class="am-notice-bar-content" | ||
> | ||
<div | ||
class="am-notice-bar-marquee-wrap " | ||
role="marquee" | ||
style="overflow:hidden;" | ||
> | ||
<div | ||
class="am-notice-bar-marquee" | ||
style="position:relative;right:0;white-space:nowrap;display:inline-block;" | ||
> | ||
foo | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
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,35 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import NoticeBar from '../index'; | ||
|
||
describe('NoticeBar', () => { | ||
it('renders correctly', () => { | ||
const wrapper = renderer.create(<NoticeBar>foo</NoticeBar>); | ||
expect(wrapper.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
describe('onClick', () => { | ||
let handleClick; | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
handleClick = jest.fn(); | ||
wrapper = shallow( | ||
<NoticeBar mode="closable" onClick={handleClick}> | ||
Notice: The arrival time of incomes and | ||
</NoticeBar>, | ||
); | ||
wrapper.find('TouchableWithoutFeedback').simulate('press'); | ||
}); | ||
|
||
it('fires onClick event', () => { | ||
expect(handleClick).toBeCalledWith(); | ||
}); | ||
|
||
it('change state', () => { | ||
expect(wrapper.state('show')).toBe(false); | ||
}); | ||
}); | ||
}); |
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,34 @@ | ||
import React from 'react'; | ||
import { render, shallow } from 'enzyme'; | ||
import { renderToJson } from 'enzyme-to-json'; | ||
import NoticeBar from '../index.web'; | ||
|
||
describe('NoticeBar', () => { | ||
it('renders correctly', () => { | ||
const wrapper = render(<NoticeBar>foo</NoticeBar>); | ||
expect(renderToJson(wrapper)).toMatchSnapshot(); | ||
}); | ||
|
||
describe('onClick', () => { | ||
let handleClick; | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
handleClick = jest.fn(); | ||
wrapper = shallow( | ||
<NoticeBar mode="closable" onClick={handleClick}> | ||
Notice: The arrival time of incomes and | ||
</NoticeBar>, | ||
); | ||
wrapper.find('.am-notice-bar-operation').simulate('click'); | ||
}); | ||
|
||
it('fires onClick event', () => { | ||
expect(handleClick).toBeCalledWith(); | ||
}); | ||
|
||
it('change state', () => { | ||
expect(wrapper.state('show')).toBe(false); | ||
}); | ||
}); | ||
}); |