Skip to content

Commit 6bb4f2b

Browse files
author
rulishu
committed
fix(Empty): 修改Empty测试用例报错
1 parent 6ea28f2 commit 6bb4f2b

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

packages/core/src/Empty/index.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ import React, { Component } from 'react';
22
import { StyleSheet, Text, TextProps } from 'react-native';
33
import Icon from '../Icon';
44
import Flex, { FlexProps } from '../Flex';
5+
import { iconStr } from './svg';
56

6-
const iconStr = `
7-
<svg width="64" height="41" viewBox="0 0 64 41">
8-
<g transform="translate(0 1)" fill="none" fill-rule="evenodd">
9-
<ellipse fill="#F5F5F5" cx="32" cy="33" rx="32" ry="7"></ellipse>
10-
<g fill-rule="nonzero" stroke="#D9D9D9">
11-
<path fill="#FFF" d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path>
12-
<path fill="#FAFAFA" d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"></path>
13-
</g>
14-
</g>
15-
</svg>
16-
`;
7+
// export const iconStr = `
8+
// <svg width="64" height="41" viewBox="0 0 64 41">
9+
// <g transform="translate(0 1)" fill="none" fill-rule="evenodd">
10+
// <ellipse fill="#F5F5F5" cx="32" cy="33" rx="32" ry="7"></ellipse>
11+
// <g fill-rule="nonzero" stroke="#D9D9D9">
12+
// <path fill="#FFF" d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path>
13+
// <path fill="#FAFAFA" d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"></path>
14+
// </g>
15+
// </g>
16+
// </svg>
17+
// `;
1718

1819
export interface EmptyProps extends FlexProps {
1920
/**

packages/core/src/Empty/svg.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export const iconStr = `
2+
<svg width="64" height="41" viewBox="0 0 64 41">
3+
<g transform="translate(0 1)" fill="none" fill-rule="evenodd">
4+
<ellipse fill="#F5F5F5" cx="32" cy="33" rx="32" ry="7"></ellipse>
5+
<g fill-rule="nonzero" stroke="#D9D9D9">
6+
<path fill="#FFF" d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path>
7+
<path fill="#FAFAFA" d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"></path>
8+
</g>
9+
</g>
10+
</svg>
11+
`;

test-ci/src/__tests__/empty.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ import React from 'react';
77
import Empty from '../lib/Empty';
88
// Note: test renderer must be required after react-native.
99
import renderer from 'react-test-renderer';
10+
import { iconStr } from '../lib/Empty/svg';
1011

1112
it('Empty', () => {
1213
const component = renderer.create(
13-
<Empty label="冇得数据咯" size={120} labelStyle={{ color: 'red' }}>冇得数据咯</Empty>
14+
<Empty label="冇得数据咯" size={120} labelStyle={{ color: 'red' }} xml={iconStr}>
15+
冇得数据咯
16+
</Empty>,
1417
);
1518
expect(component.root.props.label).toBe('冇得数据咯');
1619
expect(component.root.props.size).toBe(120);
1720
expect(component.root.props.labelStyle).toBeTruthy();
18-
expect(component.root.props.xml).toBeTruthy();
21+
expect(component.root.props.xml).toStrictEqual(iconStr);
1922
expect(component.root.props.children).toBe('冇得数据咯');
20-
21-
});
23+
});

0 commit comments

Comments
 (0)