2023-02-27 15:35:22 +08:00
|
|
|
import React from 'react';
|
|
|
|
import Layout from '..';
|
|
|
|
import { render } from '../../../tests/utils';
|
|
|
|
import ConfigProvider from '../../config-provider';
|
|
|
|
import Menu from '../../menu';
|
|
|
|
|
|
|
|
const { Header } = Layout;
|
|
|
|
|
|
|
|
describe('Layout.Token', () => {
|
2023-06-06 16:11:18 +08:00
|
|
|
it('legacy theme should work', () => {
|
2023-02-27 15:35:22 +08:00
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
theme={{
|
|
|
|
components: {
|
|
|
|
Layout: {
|
|
|
|
colorBgHeader: '#FF0000',
|
|
|
|
},
|
|
|
|
Menu: {
|
2023-06-06 16:11:18 +08:00
|
|
|
// keep this deprecated one
|
2023-02-27 15:35:22 +08:00
|
|
|
colorItemBg: '#00FF00',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Header>
|
|
|
|
<Menu
|
|
|
|
mode="horizontal"
|
|
|
|
defaultSelectedKeys={['2']}
|
|
|
|
items={new Array(15).fill(null).map((_, index) => {
|
|
|
|
const key = index + 1;
|
|
|
|
return {
|
|
|
|
key,
|
|
|
|
label: `nav ${key}`,
|
|
|
|
};
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
</Header>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
2023-06-06 16:11:18 +08:00
|
|
|
expect(container.querySelector('.ant-layout-header')).toHaveStyle({
|
|
|
|
backgroundColor: '#FF0000',
|
|
|
|
});
|
|
|
|
expect(container.querySelector('.ant-menu')).toHaveStyle({
|
|
|
|
backgroundColor: '#00FF00',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('theme should work', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
theme={{
|
|
|
|
components: {
|
|
|
|
Layout: {
|
|
|
|
colorBgHeader: '#FF0000',
|
|
|
|
},
|
|
|
|
Menu: {
|
|
|
|
itemBg: '#00FF00',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Header>
|
|
|
|
<Menu
|
|
|
|
mode="horizontal"
|
|
|
|
defaultSelectedKeys={['2']}
|
|
|
|
items={new Array(15).fill(null).map((_, index) => {
|
|
|
|
const key = index + 1;
|
|
|
|
return {
|
|
|
|
key,
|
|
|
|
label: `nav ${key}`,
|
|
|
|
};
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
</Header>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
2023-02-27 15:35:22 +08:00
|
|
|
expect(container.querySelector('.ant-layout-header')).toHaveStyle({
|
|
|
|
backgroundColor: '#FF0000',
|
|
|
|
});
|
|
|
|
expect(container.querySelector('.ant-menu')).toHaveStyle({
|
|
|
|
backgroundColor: '#00FF00',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|