Skip to content

Commit

Permalink
fix: test fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyatong committed Oct 24, 2024
1 parent ba2c8d5 commit 517b36b
Show file tree
Hide file tree
Showing 30 changed files with 88 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`should match snapshot 1`] = `
<div>
<button
class="nut-button nut-button-primary nut-button-normal nut-button-round aa"
class="nut-button nut-button-primary nut-button-primary-solid nut-button-normal nut-button-round aa"
style="margin: 8px;"
type="button"
>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/button/__test__/button.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test('should have righticon correctly', () => {
主要按钮
</Button>
)
expect(getByText('主要按钮')).toHaveClass('right')
expect(getByText('主要按钮')).toHaveClass('nut-button-text-right')
})

test('should props color when use fill correctly', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/button/button.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const Button = React.forwardRef<HTMLButtonElement, Partial<ButtonProps>>(
{!loading && icon ? icon : null}
{children && (
<View
className={`nut-button-children nut-button-${size}-children nut-button-${type}-children ${!(props.fill || disabled || loading) ? '' : `nut-button-${type}${props.fill ? `-${fill}` : ''}${disabled || loading ? '-disabled' : ''}`} ${icon || loading ? `nut-button-text` : ''}${
className={`nut-button-children nut-button-${size}-children nut-button-${type}-children ${!(props.fill || disabled || loading) ? '' : `nut-button-${type}${props.fill ? `-${fill}` : ''}${disabled || loading ? '-disabled' : ''}`}${icon || loading ? ` nut-button-text` : ''}${
rightIcon ? ` nut-button-text-right` : ''
}`}
style={harmonyAndRn() ? getContStyle() : {}}
Expand Down
2 changes: 1 addition & 1 deletion src/packages/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const Button = React.forwardRef<HTMLButtonElement, Partial<ButtonProps>>(
{!loading && icon ? icon : null}
{children && (
<div
className={` ${props.fill || disabled || loading ? `nut-button-${type}${props.fill ? `-${fill}` : ''}${disabled || loading ? '-disabled' : ''}` : ''} ${icon || loading ? 'nut-button-text' : ''}${
className={`${props.fill || disabled || loading ? `nut-button-${type}${props.fill ? `-${fill}` : ''}${disabled || loading ? '-disabled' : ''}` : ''}${icon || loading ? ' nut-button-text' : ''}${
rightIcon ? ' nut-button-text-right' : ''
}`}
>
Expand Down
10 changes: 5 additions & 5 deletions src/packages/divider/__test__/divider.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ test('custom style test', () => {
const { container } = render(
<Divider
style={{
color: '#1989fa',
borderColor: '#1989fa',
color: '#0073ff',
borderColor: '#0073ff',
padding: '0 16px',
}}
>
Expand All @@ -37,7 +37,7 @@ test('custom style test', () => {
)
expect(container.querySelector('.nut-divider')).toHaveAttribute(
'style',
'color: #1989fa; border-color: #1989fa; padding: 0px 16px;'
'color: #0073ff; border-color: #0073ff; padding: 0px 16px;'
)
})

Expand All @@ -46,11 +46,11 @@ test('prop direction vertical test', () => {
<div style={{ fontSize: '14px', marginLeft: '27px', color: '#909ca4' }}>
文本
<Divider direction="vertical" />
<a href="#/" style={{ color: '#1989fa' }}>
<a href="#/" style={{ color: '#0073ff' }}>
链接
</a>
<Divider direction="vertical" />
<a href="#/" style={{ color: '#1989fa' }}>
<a href="#/" style={{ color: '#0073ff' }}>
链接
</a>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/packages/divider/demos/h5/demo5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const Demo5 = () => {
<Cell>
<Divider
style={{
color: '#1989fa',
borderColor: '#1989fa',
color: '#0073ff',
borderColor: '#0073ff',
padding: '0 16px',
borderStyle: 'dashed',
}}
Expand Down
4 changes: 2 additions & 2 deletions src/packages/divider/demos/h5/demo6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const Demo6 = () => {
<Cell align="center">
文本
<Divider direction="vertical" />
<a href="#" style={{ color: '#1989fa' }}>
<a href="#" style={{ color: '#0073ff' }}>
链接
</a>
<Divider direction="vertical" />
<a href="#" style={{ color: '#1989fa' }}>
<a href="#" style={{ color: '#0073ff' }}>
链接
</a>
</Cell>
Expand Down
4 changes: 2 additions & 2 deletions src/packages/divider/demos/taro/demo5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const Demo5 = () => {
<Cell>
<Divider
style={{
color: '#1989fa',
color: '#0073ff',
paddingLeft: pxTransform(16),
paddingRight: pxTransform(16),
borderColor: '#1989fa',
borderColor: '#0073ff',
borderStyle: rn() ? 'solid' : 'dashed',
}}
>
Expand Down
4 changes: 2 additions & 2 deletions src/packages/divider/demos/taro/demo6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const Demo6 = () => {
<Cell align="center">
<Text>文本</Text>
<Divider direction="vertical" />
<Text style={{ color: '#1989fa' }}>链接</Text>
<Text style={{ color: '#0073ff' }}>链接</Text>
<Divider direction="vertical" />
<Text style={{ color: '#1989fa' }}>链接</Text>
<Text style={{ color: '#0073ff' }}>链接</Text>
</Cell>
)
}
Expand Down
16 changes: 8 additions & 8 deletions src/packages/grid/__test__/__snapshots__/grid.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ exports[`render with custom content 1`] = `
class="nut-grid-item-text nut-grid-item-text-horizontal"
>
<div
class="nut-avatar nut-avatar-normal nut-avatar-round demo-avatar"
class="nut-avatar nut-avatar-normal nut-avatar-round nut-avatar-normal-round demo-avatar"
style="background-color: #FF0F23; color: #666;"
>
<svg
aria-labelledby="Image"
class="nut-icon nut-icon-Image icon"
class="nut-icon nut-icon-Image nut-avatar-icon"
color="#fff"
role="presentation"
viewBox="0 0 1024 1024"
Expand Down Expand Up @@ -86,12 +86,12 @@ exports[`render with custom content 1`] = `
class="nut-grid-item-content nut-grid-item-content-border nut-grid-item-content-center nut-grid-item-content-horizontal"
>
<div
class="nut-avatar nut-avatar-normal nut-avatar-round demo-avatar"
class="nut-avatar nut-avatar-normal nut-avatar-round nut-avatar-normal-round demo-avatar"
style="background-color: #FF0F23; color: #666;"
>
<svg
aria-labelledby="Image"
class="nut-icon nut-icon-Image icon"
class="nut-icon nut-icon-Image nut-avatar-icon"
color="#fff"
role="presentation"
viewBox="0 0 1024 1024"
Expand Down Expand Up @@ -120,20 +120,20 @@ exports[`render with custom content 1`] = `
class="nut-grid-item-content nut-grid-item-content-border nut-grid-item-content-center nut-grid-item-content-horizontal"
>
<div
class="nut-avatar nut-avatar-large nut-avatar-round"
class="nut-avatar nut-avatar-large nut-avatar-round nut-avatar-large-round"
style="background-color: #eee; color: #666;"
>
<div
class="nut-image icon"
class="nut-image nut-avatar-icon"
>
<img
alt=""
class="nut-img"
class="nut-image-default"
src="https://img12.360buyimg.com/imagetools/jfs/t1/143702/31/16654/116794/5fc6f541Edebf8a57/4138097748889987.png"
style="object-fit: fill; object-position: center;"
/>
<div
class="nut-img-loading"
class="nut-image-loading"
>
<svg
aria-labelledby="Image"
Expand Down
4 changes: 2 additions & 2 deletions src/packages/image/__test__/__snapshots__/image.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ exports[`image props test 1`] = `
>
<img
alt=""
class="nut-img"
class="nut-image-default"
src="https://img10.360buyimg.com/ling/jfs/t1/181258/24/10385/53029/60d04978Ef21f2d42/92baeb21f907cd24.jpg"
style="object-fit: fill; object-position: center;"
/>
<div
class="nut-img-loading"
class="nut-image-loading"
>
<svg
aria-labelledby="Image"
Expand Down
6 changes: 3 additions & 3 deletions src/packages/image/__test__/image.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ test('image props test', () => {
'style',
'height: 100px; width: 100px;'
)
expect(container.querySelector('.nut-img')).toHaveAttribute(
expect(container.querySelector('.nut-image-default')).toHaveAttribute(
'src',
'https://img10.360buyimg.com/ling/jfs/t1/181258/24/10385/53029/60d04978Ef21f2d42/92baeb21f907cd24.jpg'
)
expect(container.querySelector('.nut-img')).toHaveAttribute(
expect(container.querySelector('.nut-image-default')).toHaveAttribute(
'style',
'object-fit: fill; object-position: center;'
)
Expand All @@ -27,7 +27,7 @@ test('image position test', () => {
const { container } = render(
<Image src={src} width="100" height="100" fit="cover" position="left" />
)
expect(container.querySelector('.nut-img')).toHaveAttribute(
expect(container.querySelector('.nut-image-default')).toHaveAttribute(
'style',
'object-fit: cover; object-position: left;'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ exports[`should match snapshot 1`] = `
class="nut-pagination"
>
<div
class="nut-pagination-prev disabled"
class="nut-pagination-prev nut-pagination-prev-disabled"
>
上一页
</div>
<div
class="nut-pagination-contain"
>
<div
class="nut-pagination-item active"
class="nut-pagination-item nut-pagination-item-active"
>
1
</div>
Expand Down
14 changes: 10 additions & 4 deletions src/packages/pagination/__tests__/pagination.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test('should emit change event after clicking visible option', async () => {

expect(container.querySelectorAll('.nut-pagination-item')).toHaveLength(5)
expect(container.querySelectorAll('.nut-pagination-item')[1]).toHaveClass(
'active'
'nut-pagination-item-active'
)
})

Expand Down Expand Up @@ -93,7 +93,9 @@ test('test controlled mode', () => {
const { container, getByText } = render(
<Pagination value={value} total={25} pageSize={5} onChange={pageChange} />
)
expect(container.querySelector('.active')).toHaveTextContent('2')
expect(
container.querySelector('.nut-pagination-item-active')
).toHaveTextContent('2')
const page = getByText('4')
fireEvent.click(page)
expect(value).toEqual(4)
Expand All @@ -112,9 +114,13 @@ test('test uncontrolled mode', () => {
onChange={pageChange}
/>
)
expect(container.querySelector('.active')).toHaveTextContent('2')
expect(
container.querySelector('.nut-pagination-item-active')
).toHaveTextContent('2')
const page = getByText('4')
fireEvent.click(page)
expect(value).toEqual(4)
expect(container.querySelector('.active')).toHaveTextContent('4')
expect(
container.querySelector('.nut-pagination-item-active')
).toHaveTextContent('4')
})
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports[`should render progress when use props 1`] = `
>
<div
class="nut-progress-inner"
style="width: 100%;"
style="width: 100%; background-color: #FF0F23;"
/>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/packages/progress/__tests__/progress.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ test('should render different height and color when use color height props', asy
<Progress percent={50} color="blue" strokeWidth="20" />
)
const inner = container.querySelector('.nut-progress-inner')
expect(inner?.getAttribute('style')).toBe('width: 50%; background: blue;')
expect(inner?.getAttribute('style')).toBe(
'width: 50%; background-color: blue;'
)
})

test('should show percent when use showText props', () => {
Expand Down
63 changes: 8 additions & 55 deletions src/packages/range/__test__/__snapshots__/range.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ exports[`range props test 1`] = `
<div>
<div
class="nut-range-container test-range"
style="color: red;"
>
<div
class="min"
class="nut-range-min"
>
0
</div>
Expand All @@ -19,12 +20,15 @@ exports[`range props test 1`] = `
>
<div
class="nut-range-button-wrapper"
style="transform: translate(-50%, -50%);"
>
<div
class="nut-range-button"
style="transform: translate(-50%, -50%);"
>
<div
class="number"
class="nut-range-button-number"
style="transform: translate(-50%, -100%);"
>
40
</div>
Expand All @@ -33,63 +37,12 @@ exports[`range props test 1`] = `
</div>
</div>
<div
class="max"
class="nut-range-max"
>
100
</div>
</div>
</div>
`;

exports[`range props test 2`] = `
<div>
<div
class="nut-range-container test-range"
>
<div
class="min"
>
0
</div>
<div
class="nut-range"
>
<div
class="nut-range-bar"
style="width: 40%; left: 0%; transition: none;"
>
<div
class="nut-range-button-wrapper"
>
<div
class="nut-range-button"
>
<div
class="number"
>
40
</div>
</div>
</div>
</div>
</div>
<div
class="max"
>
100
</div>
</div>
</div>
`;

exports[`range test 1`] = `
"<div><div class="nut-range-container"><div class="min">0</div><div class="nut-range"><div class="nut-range-bar" style="width: 30%; left: 30%; transition: none;"><div class="nut-range-button-wrapper-left
"><div class="nut-range-button"><div class="number">30</div></div></div><div class="
nut-range-button-wrapper-right"><div class="nut-range-button"><div class="number">60</div></div></div></div></div><div class="max">100</div></div></div>"
`;

exports[`range test 2`] = `
"<div><div class="nut-range-container"><div class="min">0</div><div class="nut-range"><div class="nut-range-bar" style="width: 30%; left: 30%; transition: none;"><div class="nut-range-button-wrapper-left
"><div class="nut-range-button"><div class="number">30</div></div></div><div class="
nut-range-button-wrapper-right"><div class="nut-range-button"><div class="number">60</div></div></div></div></div><div class="max">100</div></div></div>"
`;
exports[`range test 1`] = `"<div><div class="nut-range-container"><div class="nut-range-min">0</div><div class="nut-range"><div class="nut-range-bar" style="width: 30%; left: 30%; transition: none;"><div class="nut-range-button-wrapper-left" style="transform: translate(-50%, -50%);"><div class="nut-range-button" style="transform: translate(-50%, -50%);"><div class="nut-range-button-number" style="transform: translate(-50%, -100%);">30</div></div></div><div class="nut-range-button-wrapper-right" style="transform: translate(-50%, -50%);"><div class="nut-range-button" style="transform: translate(-50%, -50%);"><div class="nut-range-button-number" style="transform: translate(-50%, -100%);">60</div></div></div></div></div><div class="nut-range-max">100</div></div></div>"`;
Loading

0 comments on commit 517b36b

Please sign in to comment.