2022-02-10 20:15:39 +08:00
|
|
|
import React = require('react');
|
|
|
|
import {render} from '@testing-library/react';
|
2022-06-01 11:25:29 +08:00
|
|
|
import * as renderer from 'react-test-renderer';
|
2022-06-02 10:00:09 +08:00
|
|
|
import '../../src';
|
|
|
|
import {render as amisRender} from '../../src';
|
2022-02-10 20:15:39 +08:00
|
|
|
import {makeEnv} from '../helper';
|
|
|
|
|
|
|
|
test('Renderer:card', () => {
|
|
|
|
const {container} = render(
|
|
|
|
amisRender(
|
|
|
|
{
|
|
|
|
type: 'page',
|
|
|
|
body: {
|
|
|
|
type: 'card',
|
2022-06-01 11:25:29 +08:00
|
|
|
className: 'className',
|
2022-02-10 20:15:39 +08:00
|
|
|
header: {
|
2022-06-01 11:25:29 +08:00
|
|
|
title: '标题'
|
2022-02-10 20:15:39 +08:00
|
|
|
},
|
2022-06-01 11:25:29 +08:00
|
|
|
href: 'href',
|
2022-02-10 20:15:39 +08:00
|
|
|
body: '这里是内容',
|
2022-06-01 11:25:29 +08:00
|
|
|
bodyClassName: 'bodyClassName',
|
2022-02-10 20:15:39 +08:00
|
|
|
actions: [
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
label: '编辑',
|
|
|
|
actionType: 'dialog',
|
|
|
|
dialog: {
|
|
|
|
title: '编辑',
|
|
|
|
body: '你正在编辑该卡片'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
label: '删除',
|
|
|
|
actionType: 'dialog',
|
|
|
|
dialog: {
|
|
|
|
title: '提示',
|
|
|
|
body: '你删掉了该卡片'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
makeEnv({})
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Renderer:cards color', () => {
|
|
|
|
const {container} = render(
|
|
|
|
amisRender(
|
|
|
|
{
|
|
|
|
type: 'page',
|
|
|
|
data: {
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
engine: 'Trident',
|
|
|
|
browser: 'Internet Explorer 4.0'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
engine: 'Chrome',
|
|
|
|
browser: 'Chrome 44'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
engine: 'Gecko',
|
|
|
|
browser: 'Firefox 1.0'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
engine: 'Presto',
|
|
|
|
browser: 'Opera 10'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
engine: 'Webkie',
|
|
|
|
browser: 'Safari 12'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
body: {
|
|
|
|
type: 'cards',
|
|
|
|
source: '$items',
|
|
|
|
card: {
|
|
|
|
header: {
|
|
|
|
avatarText: '${engine|substring:0:2|upperCase}',
|
|
|
|
avatarTextBackground: [
|
|
|
|
'#FFB900',
|
|
|
|
'#D83B01',
|
|
|
|
'#B50E0E',
|
|
|
|
'#E81123',
|
|
|
|
'#B4009E',
|
|
|
|
'#5C2D91',
|
|
|
|
'#0078D7',
|
|
|
|
'#00B4FF',
|
|
|
|
'#008272'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
body: [
|
|
|
|
{
|
|
|
|
label: 'Browser',
|
|
|
|
name: 'browser'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
makeEnv({})
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Renderer:cards media', () => {
|
|
|
|
const {container} = render(
|
|
|
|
amisRender(
|
|
|
|
{
|
|
|
|
type: 'page',
|
|
|
|
body: {
|
|
|
|
type: 'card',
|
|
|
|
header: {
|
|
|
|
title: '标题'
|
|
|
|
},
|
|
|
|
media: {
|
|
|
|
type: 'image',
|
|
|
|
className: 'w-36 h-24',
|
|
|
|
url: 'https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80',
|
2022-06-01 11:25:29 +08:00
|
|
|
position: 'left',
|
|
|
|
isLive: false,
|
|
|
|
autoPlay: false,
|
|
|
|
poster: false
|
2022-02-10 20:15:39 +08:00
|
|
|
},
|
|
|
|
body: '这里是内容',
|
|
|
|
secondary: '次要说明',
|
|
|
|
actions: [
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
label: '操作',
|
|
|
|
actionType: 'dialog',
|
|
|
|
className: 'mr-4',
|
|
|
|
dialog: {
|
|
|
|
title: '操作',
|
|
|
|
body: '你正在编辑该卡片'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
label: '操作',
|
|
|
|
actionType: 'dialog',
|
|
|
|
className: 'mr-2.5',
|
|
|
|
dialog: {
|
|
|
|
title: '操作',
|
|
|
|
body: '你正在编辑该卡片'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'dropdown-button',
|
|
|
|
level: 'link',
|
2022-05-19 13:32:18 +08:00
|
|
|
icon: 'fa fa-ellipsis-h',
|
|
|
|
className: 'pr-1 flex',
|
|
|
|
hideCaret: true,
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
label: '编辑',
|
|
|
|
actionType: 'dialog',
|
|
|
|
dialog: {
|
|
|
|
title: '编辑',
|
|
|
|
body: '你正在编辑该卡片'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
label: '删除',
|
|
|
|
actionType: 'dialog',
|
|
|
|
dialog: {
|
|
|
|
title: '提示',
|
|
|
|
body: '你删掉了该卡片'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
toolbar: [
|
|
|
|
{
|
|
|
|
type: 'tpl',
|
|
|
|
tpl: '标签',
|
|
|
|
className: 'label label-warning'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
makeEnv({})
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Renderer:cards hightlight', () => {
|
|
|
|
const {container} = render(
|
|
|
|
amisRender(
|
|
|
|
{
|
|
|
|
type: 'page',
|
|
|
|
body: {
|
|
|
|
type: 'card',
|
|
|
|
header: {
|
|
|
|
title: '标题',
|
|
|
|
highlight: true,
|
|
|
|
highlightClassName: 'test-highlight-class'
|
|
|
|
},
|
|
|
|
media: {
|
|
|
|
type: 'image',
|
|
|
|
className: 'w-36 h-24',
|
|
|
|
url: 'https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80',
|
|
|
|
position: 'left'
|
|
|
|
},
|
|
|
|
body: '这里是内容',
|
|
|
|
secondary: '次要说明',
|
|
|
|
actions: [
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
label: '操作',
|
|
|
|
actionType: 'dialog',
|
|
|
|
className: 'mr-4',
|
|
|
|
dialog: {
|
|
|
|
title: '操作',
|
|
|
|
body: '你正在编辑该卡片'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
label: '操作',
|
|
|
|
actionType: 'dialog',
|
|
|
|
className: 'mr-2.5',
|
|
|
|
dialog: {
|
|
|
|
title: '操作',
|
|
|
|
body: '你正在编辑该卡片'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'dropdown-button',
|
|
|
|
level: 'link',
|
2022-02-10 20:15:39 +08:00
|
|
|
icon: 'fa fa-ellipsis-h',
|
|
|
|
className: 'pr-1 flex',
|
|
|
|
hideCaret: true,
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
label: '编辑',
|
|
|
|
actionType: 'dialog',
|
|
|
|
dialog: {
|
|
|
|
title: '编辑',
|
|
|
|
body: '你正在编辑该卡片'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
label: '删除',
|
|
|
|
actionType: 'dialog',
|
|
|
|
dialog: {
|
|
|
|
title: '提示',
|
|
|
|
body: '你删掉了该卡片'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
toolbar: [
|
|
|
|
{
|
|
|
|
type: 'tpl',
|
|
|
|
tpl: '标签',
|
|
|
|
className: 'label label-warning'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
makeEnv({})
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
2022-06-01 11:25:29 +08:00
|
|
|
|
2022-06-01 15:06:00 +08:00
|
|
|
test('Renderer:cards hightlight', () => {
|
2022-06-01 11:25:29 +08:00
|
|
|
const {container} = render(
|
|
|
|
amisRender(
|
|
|
|
{
|
|
|
|
type: 'page',
|
|
|
|
body: {
|
|
|
|
type: 'card',
|
|
|
|
header: {
|
|
|
|
title: '标题',
|
2022-06-01 15:06:00 +08:00
|
|
|
highlight: true,
|
|
|
|
highlightClassName: 'test-highlight-class'
|
2022-06-01 11:25:29 +08:00
|
|
|
},
|
2022-06-01 15:06:00 +08:00
|
|
|
media: {
|
|
|
|
type: 'image',
|
|
|
|
className: 'w-36 h-24',
|
|
|
|
url: 'https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80',
|
|
|
|
position: 'left'
|
2022-06-01 11:25:29 +08:00
|
|
|
},
|
|
|
|
body: '这里是内容',
|
2022-06-01 15:06:00 +08:00
|
|
|
secondary: '次要说明',
|
2022-06-01 11:25:29 +08:00
|
|
|
actions: [
|
|
|
|
{
|
|
|
|
type: 'button',
|
2022-06-01 15:06:00 +08:00
|
|
|
label: '操作',
|
2022-06-01 11:25:29 +08:00
|
|
|
actionType: 'dialog',
|
2022-06-01 15:06:00 +08:00
|
|
|
className: 'mr-4',
|
2022-06-01 11:25:29 +08:00
|
|
|
dialog: {
|
2022-06-01 15:06:00 +08:00
|
|
|
title: '操作',
|
2022-06-01 11:25:29 +08:00
|
|
|
body: '你正在编辑该卡片'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'button',
|
2022-06-01 15:06:00 +08:00
|
|
|
label: '操作',
|
2022-06-01 11:25:29 +08:00
|
|
|
actionType: 'dialog',
|
2022-06-01 15:06:00 +08:00
|
|
|
className: 'mr-2.5',
|
2022-06-01 11:25:29 +08:00
|
|
|
dialog: {
|
2022-06-01 15:06:00 +08:00
|
|
|
title: '操作',
|
|
|
|
body: '你正在编辑该卡片'
|
2022-06-01 11:25:29 +08:00
|
|
|
}
|
2022-06-01 15:06:00 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'dropdown-button',
|
|
|
|
level: 'link',
|
|
|
|
icon: 'fa fa-ellipsis-h',
|
|
|
|
className: 'pr-1 flex',
|
|
|
|
hideCaret: true,
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
label: '编辑',
|
|
|
|
actionType: 'dialog',
|
|
|
|
dialog: {
|
|
|
|
title: '编辑',
|
|
|
|
body: '你正在编辑该卡片'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
label: '删除',
|
|
|
|
actionType: 'dialog',
|
|
|
|
dialog: {
|
|
|
|
title: '提示',
|
|
|
|
body: '你删掉了该卡片'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
toolbar: [
|
|
|
|
{
|
|
|
|
type: 'tpl',
|
|
|
|
tpl: '标签',
|
|
|
|
className: 'label label-warning'
|
2022-06-01 11:25:29 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
makeEnv({})
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|