import React from 'react'; import { mount } from 'enzyme'; import Descriptions from '..'; const DescriptionsItem = Descriptions.Item; jest.mock('enquire.js', () => { let that; let unmatchFun; return { unregister: jest.fn(), register: (media, options) => { if (media === '(max-width: 575px)') { that = this; options.match.call(that); unmatchFun = options.unmatch; } }, callunmatch() { unmatchFun.call(that); }, }; }); describe('Descriptions', () => { it('when max-width: 575px,column=1', () => { // eslint-disable-next-line global-require const enquire = require('enquire.js'); const wrapper = mount( Cloud Database Prepaid 18:00:00 $80.00 , ); expect(wrapper.find('tr')).toHaveLength(4); enquire.callunmatch(); wrapper.unmount(); }); it('when max-width: 575px,column=2', () => { // eslint-disable-next-line global-require const enquire = require('enquire.js'); const wrapper = mount( Cloud Database Prepaid 18:00:00 $80.00 , ); expect(wrapper.find('tr')).toHaveLength(2); enquire.callunmatch(); wrapper.unmount(); }); it('column is number', () => { // eslint-disable-next-line global-require const wrapper = mount( Cloud Database Prepaid 18:00:00 $80.00 , ); expect(wrapper).toMatchSnapshot(); wrapper.unmount(); }); it('when typeof column is object', () => { const wrapper = mount( Cloud Database Prepaid 18:00:00 $80.00 , ); expect(wrapper.instance().getColumn()).toBe(8); wrapper.unmount(); }); });