Diff
checker
Testo
Testo
Immagini
Documenti
Excel
Cartelle
Legal
Enterprise
Applicazione per desktop
Prezzi
Accedi
Scarica Diffchecker Desktop
Confronta il testo
Trova la differenza tra due file di testo
Strumenti
Cronologia
Editor live
Nascondi spazi bianchi
Comprimi invariate
Senza a capo
Layout
Diviso
Unificato
Livello di dettaglio
Intelligente
Parola
Carattere
Stili testo
Modifica aspetto
Evidenziazione sintassi
Scegli sintassi
Ignora
Trasforma testo
Vai alla prima modifica
Modifica input
Diffchecker Desktop
Il modo più sicuro per usare Diffchecker. Ottieni l'app Diffchecker Desktop: i tuoi diff non lasciano mai il tuo computer!
Ottieni Desktop
Untitled diff
Creato
7 anni fa
Il diff non scade mai
Eliminare
Esporta
Condividere
Spiegare
0 rimozioni
Linee
Totale
Rimosso
Caratteri
Totale
Rimosso
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
74 linee
Copia tutti
7 aggiunte
Linee
Totale
Aggiunto
Caratteri
Totale
Aggiunto
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
74 linee
Copia tutti
/**
/**
* @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
*/
*/
Copia
Copiato
Copia
Copiato
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,
};
};
Copia
Copiato
Copia
Copiato
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', () => {
Copia
Copiato
Copia
Copiato
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', () => {
Copia
Copiato
Copia
Copiato
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', () => {
Copia
Copiato
Copia
Copiato
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 );
} );
} );
} );
} );
} );
} );
Diff salvati
Testo originale
Apri file
/** * @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 ); } ); } ); } );
Testo modificato
Apri file
/** * @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 ); } ); } ); } );
Trovare la differenza