mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 04:59:17 +08:00
51bd288d0a
* feat: 整理项目图标 * feat: 整理项目图标 * feat: 整理项目图标, 更新快照 * feat: 整理项目图标, 更新快照 * feat: 整理项目图标, 更新快照 * feat: 整理项目图标, 更新快照 * feat: 整理项目图标, 更新快照 * feat: 整理项目图标, 更新快照 --------- Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com>
99 lines
2.3 KiB
TypeScript
99 lines
2.3 KiB
TypeScript
import React = require('react');
|
|
import {render} from '@testing-library/react';
|
|
import '../../src';
|
|
import {render as amisRender} from '../../src';
|
|
import {makeEnv} from '../helper';
|
|
|
|
test('Renderer:status', () => {
|
|
const {container} = render(
|
|
amisRender(
|
|
{
|
|
type: 'page',
|
|
body: [
|
|
{
|
|
type: 'status',
|
|
value: 0
|
|
},
|
|
{
|
|
type: 'status',
|
|
value: 1
|
|
},
|
|
{
|
|
type: 'status',
|
|
value: 'success'
|
|
},
|
|
{
|
|
type: 'status',
|
|
value: 'pending'
|
|
},
|
|
{
|
|
type: 'status',
|
|
value: 'fail'
|
|
},
|
|
{
|
|
type: 'status',
|
|
value: 'fail'
|
|
},
|
|
{
|
|
type: 'status',
|
|
value: 'queue'
|
|
},
|
|
{
|
|
type: 'status',
|
|
value: 'schedule'
|
|
}
|
|
]
|
|
},
|
|
{},
|
|
makeEnv({})
|
|
)
|
|
);
|
|
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
test('Renderer:status source', async () => {
|
|
const setup = (value?: any) =>
|
|
render(
|
|
amisRender(
|
|
{
|
|
type: 'status',
|
|
source: {
|
|
11: {
|
|
label: 11,
|
|
icon: 'fa fa-check',
|
|
color: '#f0f'
|
|
},
|
|
success: {
|
|
label: 'custom success',
|
|
icon: 'fa fa-success',
|
|
color: '#ff0'
|
|
}
|
|
},
|
|
...(value !== undefined ? {value} : {})
|
|
},
|
|
{},
|
|
makeEnv({})
|
|
)
|
|
).container;
|
|
|
|
const value1 = setup(11).querySelector('.cxd-StatusField')!;
|
|
expect((value1 as HTMLElement).style.color).toBe('rgb(255, 0, 255)');
|
|
expect(
|
|
(value1.querySelector('.cxd-StatusField-label') as HTMLElement).innerHTML
|
|
).toBe('11');
|
|
expect((value1.querySelector('i') as HTMLElement).classList.value).toMatch(
|
|
/fa fa-check cxd-Status-icon/
|
|
);
|
|
|
|
const valueSuccess = setup('success').querySelector('.cxd-StatusField')!;
|
|
expect((valueSuccess as HTMLElement).style.color).toBe('rgb(255, 255, 0)');
|
|
expect(
|
|
(valueSuccess.querySelector('.cxd-StatusField-label') as HTMLElement)
|
|
.innerHTML
|
|
).toBe('custom success');
|
|
expect(
|
|
(valueSuccess.querySelector('i') as HTMLElement).classList.value
|
|
).toMatch(/fa fa-success cxd-Status-icon/);
|
|
});
|