@cainiaofe/cn-ui-m
Version:
42 lines (41 loc) • 1.48 kB
JavaScript
// CnBottomNavBar组件的单元测试
import React from 'react';
import { render, waitFor } from '@testing-library/react';
import { CnBottomNavBar } from '../index';
describe('CnBottomNavBar组件检查', function () {
test('renders CnBottomNavBar menuDataSource correctly', function () {
var getByText = render(React.createElement(CnBottomNavBar, { menuDataSource: [
{
title: '首页',
icon: 'home-fill',
},
{
title: '消息',
icon: 'message-fill',
},
{
title: '我的',
icon: 'user-fill',
},
] })).getByText;
expect(getByText('首页')).toBeInTheDocument();
});
var mockMenuData = [
{ key: '1', title: 'Menu 1', icon: 'icon1', url: '/menu1', children: [] },
{
key: '2',
title: 'Menu 2',
icon: 'icon2',
url: '/menu2',
children: [
{ key: '2-1', title: 'Submenu 1', icon: 'icon2-1', url: '/submenu1' },
],
},
];
it('shows more when there are secondary menus', function () {
var getByText = render(React.createElement(CnBottomNavBar, { menuDataSource: mockMenuData })).getByText;
waitFor(function () {
expect(getByText('更多')).toBeInTheDocument();
});
});
});