amis2/packages/amis/__tests__/renderers/Image.test.tsx

71 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 组件名称Image/Images 图片/图片集
* 单测内容:
* 1. Image图片
* 2. Images图片集
*/
import {render} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv} from '../helper';
describe('Renderer:image', () => {
test('image:basic', async () => {
const {container} = render(
amisRender(
{
type: 'image',
defaultImage: 'https://www.baidu.com/img/bd_logo1.png',
title: '图片',
description: '图片描述',
imageClassName: 'b',
className: 'show'
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
});
describe('Renderer:images', () => {
test('images:basic', async () => {
const {container} = render(
amisRender(
{
type: 'page',
data: {
imageList: [
'https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80',
'https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692942/d8e4992057f9.jpeg@s_0,w_216,l_1,f_jpg,q_80',
'https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693148/1314a2a3d3f6.jpeg@s_0,w_216,l_1,f_jpg,q_80',
'https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693379/8f2e79f82be0.jpeg@s_0,w_216,l_1,f_jpg,q_80',
'https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693566/552b175ef11d.jpeg@s_0,w_216,l_1,f_jpg,q_80'
]
},
body: [
{
type: 'images',
source: '${imageList}'
},
{
type: 'divider'
},
{
type: 'images',
name: 'imageList'
}
]
},
{},
makeEnv({})
)
);
expect(container).toMatchSnapshot();
});
});