Diff
checker
文本
文本
图像
文档
Excel
文件夹
Legal
Enterprise
桌面版
定价
登录
下载 Diffchecker 桌面版
比较文本
查找两个文本文件之间的差异
工具
历史
实时编辑器
隐藏空白更改
折叠未更改行
关闭换行
视图
拆分
统一
比对精度
智能
单词
字符
文本样式
更改外观
语法高亮
选择语法
忽略
文本转换
转到第一个差异
编辑输入
Diffchecker Desktop
运行Diffchecker最安全的方式。获取Diffchecker桌面应用:您的差异永远不会离开您的电脑!
获取桌面版
Untitled diff
创建于
7年前
差异永不过期
清除
导出
分享
解释
0 删除
行
总计
删除
字符
总计
删除
要继续使用此功能,请升级到
Diff
checker
Pro
查看价格
74 行
全部复制
7 添加
行
总计
添加
字符
总计
添加
要继续使用此功能,请升级到
Diff
checker
Pro
查看价格
74 行
全部复制
/**
/**
* @format
* @format
* @jest-environment jsdom
* @jest-environment jsdom
*/
*/
/**
/**
* External dependencies
* External dependencies
*/
*/
import { shallow } from 'enzyme';
import { shallow } from 'enzyme';
import React from 'react';
import React from 'react';
import { identity, noop } from 'lodash';
import { identity, noop } from 'lodash';
/**
/**
* Internal dependencies
* Internal dependencies
*/
*/
复制
已复制
复制
已复制
import { CreditCardFormFields
} from '../';
import { CreditCardFormFields
UX
} from '../';
import { shouldRenderAdditionalCountryFields } from 'lib/checkout/processor-specific';
import { shouldRenderAdditionalCountryFields } from 'lib/checkout/processor-specific';
jest.mock( 'i18n-calypso', () => ( {
jest.mock( 'i18n-calypso', () => ( {
localize: x => x,
localize: x => x,
} ) );
} ) );
jest.mock( 'lib/checkout/processor-specific', () => {
jest.mock( 'lib/checkout/processor-specific', () => {
return {
return {
shouldRenderAdditionalCountryFields: jest.fn( false ),
shouldRenderAdditionalCountryFields: jest.fn( false ),
};
};
} );
} );
// Gets rid of warnings such as 'UnhandledPromiseRejectionWarning: Error: No available storage method found.'
// Gets rid of warnings such as 'UnhandledPromiseRejectionWarning: Error: No available storage method found.'
jest.mock( 'lib/user', () => () => {} );
jest.mock( 'lib/user', () => () => {} );
const defaultProps = {
const defaultProps = {
card: {},
card: {},
countriesList: [],
countriesList: [],
eventFormName: 'A fine form',
eventFormName: 'A fine form',
translate: identity,
translate: identity,
isFieldInvalid: identity,
isFieldInvalid: identity,
onFieldChange: noop,
onFieldChange: noop,
isNewTransaction: true,
isNewTransaction: true,
};
};
复制
已复制
复制
已复制
describe( 'CreditCardFormFields
', () => {
describe( 'CreditCardFormFields
UX
', () => {
test( 'should have `CreditCardFormFields
` class', () => {
test( 'should have `CreditCardFormFields
UX
` class', () => {
const wrapper = shallow( <CreditCardFormFields
{ ...defaultProps } /> );
const wrapper = shallow( <CreditCardFormFields
UX
{ ...defaultProps } /> );
expect( wrapper.find( '.credit-card-form-fields' ) ).toHaveLength( 1 );
expect( wrapper.find( '.credit-card-form-fields' ) ).toHaveLength( 1 );
} );
} );
test( 'should not render ebanx fields', () => {
test( 'should not render ebanx fields', () => {
复制
已复制
复制
已复制
const wrapper = shallow( <CreditCardFormFields
{ ...defaultProps } /> );
const wrapper = shallow( <CreditCardFormFields
UX
{ ...defaultProps } /> );
expect( wrapper.find( 'CountrySpecificPaymentFields' ) ).toHaveLength( 0 );
expect( wrapper.find( 'CountrySpecificPaymentFields' ) ).toHaveLength( 0 );
} );
} );
describe( 'with ebanx activated', () => {
describe( 'with ebanx activated', () => {
beforeAll( () => {
beforeAll( () => {
shouldRenderAdditionalCountryFields.mockReturnValue( true );
shouldRenderAdditionalCountryFields.mockReturnValue( true );
} );
} );
afterAll( () => {
afterAll( () => {
shouldRenderAdditionalCountryFields.mockReturnValue( false );
shouldRenderAdditionalCountryFields.mockReturnValue( false );
} );
} );
test( 'should display Ebanx fields when an Ebanx payment country is selected and there is a transaction in process', () => {
test( 'should display Ebanx fields when an Ebanx payment country is selected and there is a transaction in process', () => {
复制
已复制
复制
已复制
const wrapper = shallow( <CreditCardFormFields
{ ...defaultProps } /> );
const wrapper = shallow( <CreditCardFormFields
UX
{ ...defaultProps } /> );
wrapper.setProps( { card: { country: 'BR' } } );
wrapper.setProps( { card: { country: 'BR' } } );
expect( wrapper.find( 'CountrySpecificPaymentFields' ) ).toHaveLength( 1 );
expect( wrapper.find( 'CountrySpecificPaymentFields' ) ).toHaveLength( 1 );
} );
} );
test( 'should not display Ebanx fields when there is a transaction in process', () => {
test( 'should not display Ebanx fields when there is a transaction in process', () => {
复制
已复制
复制
已复制
const wrapper = shallow( <CreditCardFormFields
{ ...defaultProps } /> );
const wrapper = shallow( <CreditCardFormFields
UX
{ ...defaultProps } /> );
wrapper.setProps( { card: { country: 'BR' }, isNewTransaction: false } );
wrapper.setProps( { card: { country: 'BR' }, isNewTransaction: false } );
expect( wrapper.find( 'CountrySpecificPaymentFields' ) ).toHaveLength( 0 );
expect( wrapper.find( 'CountrySpecificPaymentFields' ) ).toHaveLength( 0 );
} );
} );
} );
} );
} );
} );
已保存差异
原始文本
打开文件
/** * @format * @jest-environment jsdom */ /** * External dependencies */ import { shallow } from 'enzyme'; import React from 'react'; import { identity, noop } from 'lodash'; /** * Internal dependencies */ import { CreditCardFormFields } from '../'; import { shouldRenderAdditionalCountryFields } from 'lib/checkout/processor-specific'; jest.mock( 'i18n-calypso', () => ( { localize: x => x, } ) ); jest.mock( 'lib/checkout/processor-specific', () => { return { shouldRenderAdditionalCountryFields: jest.fn( false ), }; } ); // Gets rid of warnings such as 'UnhandledPromiseRejectionWarning: Error: No available storage method found.' jest.mock( 'lib/user', () => () => {} ); const defaultProps = { card: {}, countriesList: [], eventFormName: 'A fine form', translate: identity, isFieldInvalid: identity, onFieldChange: noop, isNewTransaction: true, }; describe( 'CreditCardFormFields', () => { test( 'should have `CreditCardFormFields` class', () => { const wrapper = shallow( <CreditCardFormFields { ...defaultProps } /> ); expect( wrapper.find( '.credit-card-form-fields' ) ).toHaveLength( 1 ); } ); test( 'should not render ebanx fields', () => { const wrapper = shallow( <CreditCardFormFields { ...defaultProps } /> ); expect( wrapper.find( 'CountrySpecificPaymentFields' ) ).toHaveLength( 0 ); } ); describe( 'with ebanx activated', () => { beforeAll( () => { shouldRenderAdditionalCountryFields.mockReturnValue( true ); } ); afterAll( () => { shouldRenderAdditionalCountryFields.mockReturnValue( false ); } ); test( 'should display Ebanx fields when an Ebanx payment country is selected and there is a transaction in process', () => { const wrapper = shallow( <CreditCardFormFields { ...defaultProps } /> ); wrapper.setProps( { card: { country: 'BR' } } ); expect( wrapper.find( 'CountrySpecificPaymentFields' ) ).toHaveLength( 1 ); } ); test( 'should not display Ebanx fields when there is a transaction in process', () => { const wrapper = shallow( <CreditCardFormFields { ...defaultProps } /> ); wrapper.setProps( { card: { country: 'BR' }, isNewTransaction: false } ); expect( wrapper.find( 'CountrySpecificPaymentFields' ) ).toHaveLength( 0 ); } ); } ); } );
更改后文本
打开文件
/** * @format * @jest-environment jsdom */ /** * External dependencies */ import { shallow } from 'enzyme'; import React from 'react'; import { identity, noop } from 'lodash'; /** * Internal dependencies */ import { CreditCardFormFieldsUX } from '../'; import { shouldRenderAdditionalCountryFields } from 'lib/checkout/processor-specific'; jest.mock( 'i18n-calypso', () => ( { localize: x => x, } ) ); jest.mock( 'lib/checkout/processor-specific', () => { return { shouldRenderAdditionalCountryFields: jest.fn( false ), }; } ); // Gets rid of warnings such as 'UnhandledPromiseRejectionWarning: Error: No available storage method found.' jest.mock( 'lib/user', () => () => {} ); const defaultProps = { card: {}, countriesList: [], eventFormName: 'A fine form', translate: identity, isFieldInvalid: identity, onFieldChange: noop, isNewTransaction: true, }; describe( 'CreditCardFormFieldsUX', () => { test( 'should have `CreditCardFormFieldsUX` class', () => { const wrapper = shallow( <CreditCardFormFieldsUX { ...defaultProps } /> ); expect( wrapper.find( '.credit-card-form-fields' ) ).toHaveLength( 1 ); } ); test( 'should not render ebanx fields', () => { const wrapper = shallow( <CreditCardFormFieldsUX { ...defaultProps } /> ); expect( wrapper.find( 'CountrySpecificPaymentFields' ) ).toHaveLength( 0 ); } ); describe( 'with ebanx activated', () => { beforeAll( () => { shouldRenderAdditionalCountryFields.mockReturnValue( true ); } ); afterAll( () => { shouldRenderAdditionalCountryFields.mockReturnValue( false ); } ); test( 'should display Ebanx fields when an Ebanx payment country is selected and there is a transaction in process', () => { const wrapper = shallow( <CreditCardFormFieldsUX { ...defaultProps } /> ); wrapper.setProps( { card: { country: 'BR' } } ); expect( wrapper.find( 'CountrySpecificPaymentFields' ) ).toHaveLength( 1 ); } ); test( 'should not display Ebanx fields when there is a transaction in process', () => { const wrapper = shallow( <CreditCardFormFieldsUX { ...defaultProps } /> ); wrapper.setProps( { card: { country: 'BR' }, isNewTransaction: false } ); expect( wrapper.find( 'CountrySpecificPaymentFields' ) ).toHaveLength( 0 ); } ); } ); } );
查找差异