Diff
checker
Texte
Texte
Images
Documents
Excel
Dossiers
Legal
Enterprise
Application de bureau
Prix
Se connecter
Télécharger Diffchecker Desktop
Comparer le texte
Trouver la différence entre deux fichiers texte
Outils
Historique
Éditeur live
Masquer les espaces
Cacher identiques
Sans retour à la ligne
Vue
Divisé
Unifié
Niveau de précision
Intelligent
Mot
Caractère
Styles de texte
Modifier l’apparence
Coloration syntaxique
Choisir la syntaxe
Ignorer
Transformer le texte
Aller au premier écart
Modifier l'entrée
Diffchecker Desktop
La façon la plus sécurisée d'utiliser Diffchecker. Obtenez l'application Diffchecker Desktop : vos diffs ne quittent jamais votre ordinateur !
Obtenir Desktop
Untitled diff
Créé
il y a 7 ans
Le diff n'expire jamais
Effacer
Exporter
Partager
Expliquer
0 suppressions
Lignes
Total
Supprimé
Caractères
Total
Supprimé
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
74 lignes
Copier tout
7 ajouts
Lignes
Total
Ajouté
Caractères
Total
Ajouté
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
74 lignes
Copier tout
/**
/**
* @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
*/
*/
Copier
Copié
Copier
Copié
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,
};
};
Copier
Copié
Copier
Copié
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', () => {
Copier
Copié
Copier
Copié
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', () => {
Copier
Copié
Copier
Copié
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', () => {
Copier
Copié
Copier
Copié
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érences enregistrées
Texte d'origine
Ouvrir un fichier
/** * @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 ); } ); } ); } );
Texte modifié
Ouvrir un fichier
/** * @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 ); } ); } ); } );
Trouver la différence