<commit_before>﻿import * as React from 'react';
import { shallow, mount, render } from 'enzyme';
import { PaymentSelection } from '../PaymentSelection';

describe('<PaymentSelection/>', () => {
    it('should render', () => {
        const payment = { clientType: 'uc', account: '' };
        const target = mount(<PaymentSelection payment={payment} onPaymentSelected={null} />);
        expect(target.find('div').length).toBeGreaterThan(0);
    });
    describe('<Input />', () => {
        it('should not render when other payment method', () => {
            const payment = { clientType: 'other', account: '' };
            const target = mount(<PaymentSelection payment={payment} onPaymentSelected={null} />);
            expect(target.find('Input').length).toEqual(0);
        });
        it('should render when uc payment method', () => {
            const payment = { clientType: 'uc', account: '' };
            const target = mount(<PaymentSelection payment={payment} onPaymentSelected={null} />);
            expect(target.find('Input').length).toEqual(1);
        });
        describe('Parameters', () => {
            const payment = { clientType: 'uc', account: '123' };
            const target = mount(<PaymentSelection payment={payment} onPaymentSelected={null} />);
            const input = target.find('Input').at(0);

            it('should have a type of text', () => {
                expect(input.prop('type')).toEqual('text');
            });
            it('should have a label', () => {
                expect(input.prop('label')).toEqual('UC Account');
            });
            it('should have a maxLength of 10', () => {
                expect(input.prop('maxLength')).toEqual(10);
            });
            it('should have set a value', () => {
                expect(input.prop('value')).toEqual('123');
            });
        });
    });
});<commit_msg>simulate not working as expected, so test method instead.<commit_after>﻿import * as React from 'react';
import { shallow, mount, render } from 'enzyme';
import { PaymentSelection } from '../PaymentSelection';

describe('<PaymentSelection/>', () => {
    it('should render', () => {
        const payment = { clientType: 'uc', account: '' };
        const target = mount(<PaymentSelection payment={payment} onPaymentSelected={null} />);
        expect(target.find('div').length).toBeGreaterThan(0);
    });
    describe('<Input />', () => {
        it('should not render when other payment method', () => {
            const payment = { clientType: 'other', account: '' };
            const target = mount(<PaymentSelection payment={payment} onPaymentSelected={null} />);
            expect(target.find('Input').length).toEqual(0);
        });
        it('should render when uc payment method', () => {
            const payment = { clientType: 'uc', account: '' };
            const target = mount(<PaymentSelection payment={payment} onPaymentSelected={null} />);
            expect(target.find('Input').length).toEqual(1);
        });
        describe('Parameters', () => {
            const payment = { clientType: 'uc', account: '123' };
            const target = mount(<PaymentSelection payment={payment} onPaymentSelected={null} />);
            const input = target.find('Input').at(0);

            it('should have a type of text', () => {
                expect(input.prop('type')).toEqual('text');
            });
            it('should have a label', () => {
                expect(input.prop('label')).toEqual('UC Account');
            });
            it('should have a maxLength of 10', () => {
                expect(input.prop('maxLength')).toEqual(10);
            });
            it('should have set a value', () => {
                expect(input.prop('value')).toEqual('123');
            });
        });
        it('should call onPaymentSelected when the account is changed', () => {
            const onPaymentSelected = jasmine.createSpy('onPaymentSelected');
            const payment = { clientType: 'uc', account: '123' };
            const target = mount(<PaymentSelection payment={payment} onPaymentSelected={onPaymentSelected} />);
            expect(target.find('Input').length).toEqual(1);

            const internal = target.instance();
            internal.handleAccountChange('xxx');

            expect(onPaymentSelected).toHaveBeenCalled();
            expect(onPaymentSelected).toHaveBeenCalledWith({ clientType: 'uc', account: 'xxx' });
        });
    });
});
{'fraction_non_alphanumeric': 0.17175317442637558, 'fraction_numerical': 0.007128536422365783, 'mean_word_length': 2.453846153846154, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2558255', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1121, 'n_words': 253}