ant-design/components/config-provider/__tests__/index.test.js

58 lines
1.3 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { mount } from 'enzyme';
import ConfigProvider from '..';
import Button from '../../button';
import Table from '../../table';
2019-08-26 22:53:20 +08:00
import mountTest from '../../../tests/shared/mountTest';
describe('ConfigProvider', () => {
mountTest(() => (
<ConfigProvider>
<div />
</ConfigProvider>
));
2019-08-26 22:53:20 +08:00
it('Content Security Policy', () => {
const csp = { nonce: 'test-antd' };
const wrapper = mount(
<ConfigProvider csp={csp}>
<Button />
</ConfigProvider>,
);
expect(wrapper.find('Wave').instance().csp).toBe(csp);
});
it('autoInsertSpaceInButton', () => {
const wrapper = mount(
<ConfigProvider autoInsertSpaceInButton={false}>
<Button>确定</Button>
</ConfigProvider>,
);
expect(wrapper.find('Button').text()).toBe('确定');
});
it('renderEmpty', () => {
const wrapper = mount(
<ConfigProvider renderEmpty={() => <div>empty placeholder</div>}>
<Table />
</ConfigProvider>,
);
expect(wrapper.text()).toContain('empty placeholder');
});
it('nest prefixCls', () => {
const wrapper = mount(
<ConfigProvider prefixCls="bamboo">
<ConfigProvider>
<Button />
</ConfigProvider>
</ConfigProvider>,
);
expect(wrapper.find('button').props().className).toEqual('bamboo-btn');
});
});