2018-12-05 19:12:18 +08:00
|
|
|
import React from 'react';
|
2019-01-10 11:47:11 +08:00
|
|
|
import { mount } from 'enzyme';
|
2018-12-05 19:12:18 +08:00
|
|
|
import ConfigProvider from '..';
|
|
|
|
import Button from '../../button';
|
2020-02-14 19:02:53 +08:00
|
|
|
import Table from '../../table';
|
2019-08-26 22:53:20 +08:00
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
2018-12-05 19:12:18 +08:00
|
|
|
|
|
|
|
describe('ConfigProvider', () => {
|
2019-09-02 10:47:32 +08:00
|
|
|
mountTest(() => (
|
|
|
|
<ConfigProvider>
|
|
|
|
<div />
|
|
|
|
</ConfigProvider>
|
|
|
|
));
|
2019-08-26 22:53:20 +08:00
|
|
|
|
2019-01-10 11:47:11 +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);
|
|
|
|
});
|
2018-12-05 19:12:18 +08:00
|
|
|
|
2019-01-10 11:47:11 +08:00
|
|
|
it('autoInsertSpaceInButton', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<ConfigProvider autoInsertSpaceInButton={false}>
|
|
|
|
<Button>确定</Button>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
2018-12-05 19:12:18 +08:00
|
|
|
|
2019-01-10 11:47:11 +08:00
|
|
|
expect(wrapper.find('Button').text()).toBe('确定');
|
2018-12-05 19:12:18 +08:00
|
|
|
});
|
2020-02-14 19:02:53 +08:00
|
|
|
|
|
|
|
it('renderEmpty', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<ConfigProvider renderEmpty={() => <div>empty placeholder</div>}>
|
|
|
|
<Table />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.text()).toContain('empty placeholder');
|
|
|
|
});
|
2018-12-05 19:12:18 +08:00
|
|
|
});
|