Skip to content

Commit

Permalink
✅ test: 补充测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Jun 18, 2021
1 parent 3b1a4b9 commit 08bff68
Show file tree
Hide file tree
Showing 8 changed files with 554 additions and 23 deletions.
39 changes: 39 additions & 0 deletions packages/image-gallery/src/AssetCard.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { render } from '@testing-library/react';

import AssetCard from './AssetCard';

describe('AssetCard', () => {
it('图片 Png', () => {
const { container } = render(
<AssetCard
title={'测试'}
url={
'https://gw.alipayobjects.com/zos/antfincdn/G5sZluNGGA/25c4fe16-7d52-4b32-904e-3eccb4a1ff47.png'
}
/>,
);
expect(container).toMatchSnapshot();
});
it('图片 Svg', () => {
const { container } = render(
<AssetCard
title={'Svg 测试'}
url={'https://gw.alipayobjects.com/zos/antfincdn/LFmaI3%26OJh/logo.svg'}
/>,
);
expect(container).toMatchSnapshot();
});
it('Sketch 测试', () => {
const { container } = render(
<AssetCard
title={'Sketch 测试'}
url={'https://gw.alipayobjects.com/zos/antfincdn/LFmaI3%26OJh/logo.svg'}
sketch={
'https://gw.alipayobjects.com/os/kitchen/oLQZFZVkmdvqpKRQDCuU.json'
}
/>,
);
expect(container).toMatchSnapshot();
});
});
17 changes: 17 additions & 0 deletions packages/image-gallery/src/Layout.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { render } from '@testing-library/react';

import Layout from './Layout';

describe('Layout', () => {
it('瀑布流布局', () => {
const { container } = render(<Layout layout={'masonry'} />);
expect(container).toMatchSnapshot();
});
// it('Grid 布局', () => {
// const { container } = render(
// <Layout layout={'grid'} grid={{ columns: 1 }} />,
// );
// expect(container).toMatchSnapshot();
// });
});
261 changes: 261 additions & 0 deletions packages/image-gallery/src/__snapshots__/AssetCard.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AssetCard Sketch 测试 1`] = `
<div>
<div
class="avx-image-gallery-item"
>
<div
class="ant-card ant-card-bordered"
>
<div
class="ant-card-cover"
>
<div
class="avx-image-gallery-image-ctn"
style="border-bottom: 1px solid #f3f3f3;"
>
<img
alt="Sketch 测试"
class="avx-image-gallery-image"
src="https://gw.alipayobjects.com/zos/antfincdn/LFmaI3%26OJh/logo.svg"
/>
</div>
</div>
<div
class="ant-card-body"
>
<div
class="ant-card-meta"
>
<div
class="ant-card-meta-detail"
>
<div
class="ant-card-meta-title"
>
Sketch 测试
</div>
</div>
</div>
</div>
<ul
class="ant-card-actions"
>
<li
style="width: 100%;"
>
<span>
<button
class="ant-btn ant-btn-link avx-image-gallery-link"
type="button"
>
<span>
复制 Sketch 组件
</span>
</button>
</span>
</li>
</ul>
</div>
</div>
</div>
`;

exports[`AssetCard 图片 Png 1`] = `
<div>
<div
class="avx-image-gallery-item"
>
<div
class="ant-card ant-card-bordered"
>
<div
class="ant-card-cover"
>
<div
class="avx-image-gallery-image-ctn"
style="border-bottom: 1px solid #f3f3f3;"
>
<img
alt="测试"
class="avx-image-gallery-image"
src="https://gw.alipayobjects.com/zos/antfincdn/G5sZluNGGA/25c4fe16-7d52-4b32-904e-3eccb4a1ff47.png"
/>
</div>
</div>
<div
class="ant-card-body"
>
<div
class="ant-card-meta"
>
<div
class="ant-card-meta-detail"
>
<div
class="ant-card-meta-title"
>
测试
</div>
</div>
</div>
</div>
<ul
class="ant-card-actions"
>
<li
style="width: 50%;"
>
<span>
<button
class="ant-btn ant-btn-link avx-image-gallery-link"
type="button"
>
<span>
Png
</span>
</button>
</span>
</li>
<li
style="width: 50%;"
>
<span>
<button
class="ant-btn ant-btn-link ant-dropdown-trigger avx-image-gallery-link"
type="button"
>
<span
aria-label="ellipsis"
class="anticon anticon-ellipsis"
role="img"
>
<svg
aria-hidden="true"
data-icon="ellipsis"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M176 511a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0z"
/>
</svg>
</span>
</button>
</span>
</li>
</ul>
</div>
</div>
</div>
`;

exports[`AssetCard 图片 Svg 1`] = `
<div>
<div
class="avx-image-gallery-item"
>
<div
class="ant-card ant-card-bordered"
>
<div
class="ant-card-cover"
>
<div
class="avx-image-gallery-image-ctn"
style="border-bottom: 1px solid #f3f3f3;"
>
<img
alt="Svg 测试"
class="avx-image-gallery-image"
src="https://gw.alipayobjects.com/zos/antfincdn/LFmaI3%26OJh/logo.svg"
/>
</div>
</div>
<div
class="ant-card-body"
>
<div
class="ant-card-meta"
>
<div
class="ant-card-meta-detail"
>
<div
class="ant-card-meta-title"
>
Svg 测试
</div>
</div>
</div>
</div>
<ul
class="ant-card-actions"
>
<li
style="width: 33.333333333333336%;"
>
<span>
<button
class="ant-btn ant-btn-link avx-image-gallery-link"
type="button"
>
<span>
Svg
</span>
</button>
</span>
</li>
<li
style="width: 33.333333333333336%;"
>
<span>
<button
class="ant-btn ant-btn-link avx-image-gallery-link"
type="button"
>
<span>
Png
</span>
</button>
</span>
</li>
<li
style="width: 33.333333333333336%;"
>
<span>
<button
class="ant-btn ant-btn-link ant-dropdown-trigger avx-image-gallery-link"
type="button"
>
<span
aria-label="ellipsis"
class="anticon anticon-ellipsis"
role="img"
>
<svg
aria-hidden="true"
data-icon="ellipsis"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M176 511a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0z"
/>
</svg>
</span>
</button>
</span>
</li>
</ul>
</div>
</div>
</div>
`;
9 changes: 9 additions & 0 deletions packages/image-gallery/src/__snapshots__/Layout.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Layout 瀑布流布局 1`] = `
<div>
<div
class="avx-image-gallery-container avx-image-gallery-masonry"
/>
</div>
`;
2 changes: 2 additions & 0 deletions packages/image-gallery/src/utils/sketch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* istanbul ignore file */

import copy from 'copy-to-clipboard';
import { copySuccess } from './helper';

Expand Down
Loading

0 comments on commit 08bff68

Please sign in to comment.