Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework: upgrade enzyme #19448

Merged
merged 10 commits into from
Nov 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 42 additions & 8 deletions client/account-recovery/forgot-username-form/test/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ describe( 'ForgotUsername', () => {

// Expect the fields to be disabled
inputSelectors.forEach( selector => {
expect( wrapper.find( selector ).prop( 'disabled' ) ).to.be.ok;
expect(
wrapper
.find( selector )
.first()
.prop( 'disabled' )
).to.be.ok;
} );
} );
} );
Expand All @@ -56,7 +61,12 @@ describe( 'ForgotUsername', () => {
} );

// Expect the button to be disabled
expect( wrapper.find( '.forgot-username-form__submit-button' ).prop( 'disabled' ) ).to.be.ok;
expect(
wrapper
.find( '.forgot-username-form__submit-button' )
.first()
.prop( 'disabled' )
).to.be.ok;
} );

test( 'should be disabled if lastName is blank', () => {
Expand All @@ -68,7 +78,12 @@ describe( 'ForgotUsername', () => {
} );

// Expect the button to be disabled
expect( wrapper.find( '.forgot-username-form__submit-button' ).prop( 'disabled' ) ).to.be.ok;
expect(
wrapper
.find( '.forgot-username-form__submit-button' )
.first()
.prop( 'disabled' )
).to.be.ok;
} );

test( 'should be disabled if url is blank', () => {
Expand All @@ -80,7 +95,12 @@ describe( 'ForgotUsername', () => {
} );

// Expect the button to be disabled
expect( wrapper.find( '.forgot-username-form__submit-button' ).prop( 'disabled' ) ).to.be.ok;
expect(
wrapper
.find( '.forgot-username-form__submit-button' )
.first()
.prop( 'disabled' )
).to.be.ok;
} );

test( 'should be enabled when all fields are filled in', () => {
Expand All @@ -92,8 +112,12 @@ describe( 'ForgotUsername', () => {
} );

// Expect the button to be enabled
expect( wrapper.find( '.forgot-username-form__submit-button' ).prop( 'disabled' ) ).to.not.be
.ok;
expect(
wrapper
.find( '.forgot-username-form__submit-button' )
.first()
.prop( 'disabled' )
).to.not.be.ok;
} );

test( 'should be disabled when submitted', () => {
Expand All @@ -107,10 +131,20 @@ describe( 'ForgotUsername', () => {
} );

inputSelectors.forEach( selector => {
expect( wrapper.find( selector ).prop( 'disabled' ) ).to.be.ok;
expect(
wrapper
.find( selector )
.first()
.prop( 'disabled' )
).to.be.ok;
} );

expect( wrapper.find( '.forgot-username-form__submit-button' ).prop( 'disabled' ) ).to.be.ok;
expect(
wrapper
.find( '.forgot-username-form__submit-button' )
.first()
.prop( 'disabled' )
).to.be.ok;
} );
} );
} );
14 changes: 9 additions & 5 deletions client/account-recovery/lost-password-form/test/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,23 @@ describe( 'LostPassword', () => {
const wrapper = mount( <LostPasswordFormComponent className="test__test" /> );
wrapper.setState( { userLoginFormValue: '' } );

wrapper.find( '.lost-password-form__user-login-input' ).node.value = '';
expect( wrapper.find( '.lost-password-form__user-login-input' ).prop( 'disabled' ) ).to.not.be
expect(
wrapper.find( '.form-text-input.lost-password-form__user-login-input' ).prop( 'disabled' )
).to.not.be.ok;
expect( wrapper.find( 'button.lost-password-form__submit-button' ).prop( 'disabled' ) ).to.be
.ok;
expect( wrapper.find( '.lost-password-form__submit-button' ).prop( 'disabled' ) ).to.be.ok;
} );

test( 'should be disabled when isRequesting is true', () => {
const wrapper = mount(
<LostPasswordFormComponent className="test__test" isRequesting={ true } />
);

expect( wrapper.find( '.lost-password-form__user-login-input' ).prop( 'disabled' ) ).to.be.ok;
expect( wrapper.find( '.lost-password-form__submit-button' ).prop( 'disabled' ) ).to.be.ok;
expect(
wrapper.find( '.form-text-input.lost-password-form__user-login-input' ).prop( 'disabled' )
).to.be.ok;
expect( wrapper.find( 'button.lost-password-form__submit-button' ).prop( 'disabled' ) ).to.be
.ok;
} );
} );
} );
25 changes: 20 additions & 5 deletions client/account-recovery/reset-password-form/test/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ describe( 'ResetPasswordForm', () => {

// Expect the fields to be disabled
inputSelectors.forEach( selector => {
expect( wrapper.find( selector ).prop( 'disabled' ) ).to.be.ok;
expect(
wrapper
.find( selector )
.first()
.prop( 'disabled' )
).to.be.ok;
} );
} );
} );
Expand All @@ -71,7 +76,12 @@ describe( 'ResetPasswordForm', () => {
);

// Expect the button to be disabled
expect( wrapper.find( '.reset-password-form__submit-button' ).prop( 'disabled' ) ).to.be.ok;
expect(
wrapper
.find( '.reset-password-form__submit-button' )
.first()
.prop( 'disabled' )
).to.be.ok;
} );

test( 'should be enabled if a reset option is selected', () => {
Expand All @@ -80,8 +90,12 @@ describe( 'ResetPasswordForm', () => {
);
wrapper.setState( { selectedMethod: 'primary_email' } );

expect( wrapper.find( '.reset-password-form__submit-button' ).prop( 'disabled' ) ).to.not.be
.ok;
expect(
wrapper
.find( '.reset-password-form__submit-button' )
.first()
.prop( 'disabled' )
).to.not.be.ok;
} );

test( 'should be disabled when isRequesting is true.', () => {
Expand All @@ -93,7 +107,8 @@ describe( 'ResetPasswordForm', () => {
/>
);

expect( wrapper.find( '.reset-password-form__submit-button' ).prop( 'disabled' ) ).to.be.ok;
expect( wrapper.find( 'button.reset-password-form__submit-button' ).prop( 'disabled' ) ).to.be
.ok;
} );
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,41 @@ describe( 'TransactionIdForm', () => {
test( 'continue button should be disabled if transaction id is blank', () => {
const wrapper = mount( <TransactionIdFormComponent className="test__test" /> );

wrapper.find( '.transaction-id-form__transaction-id-input' ).node.value = '';
wrapper.find( '.transaction-id-form__transaction-id-input' ).simulate( 'change' );
expect( wrapper.find( '.transaction-id-form__transaction-id-input' ).prop( 'disabled' ) ).to
.not.be.ok;
expect( wrapper.find( '.transaction-id-form__continue-button' ).prop( 'disabled' ) ).to.be.ok;
wrapper
.find( '.form-text-input.transaction-id-form__transaction-id-input' )
.simulate( 'change' );
expect(
wrapper
.find( '.transaction-id-form__transaction-id-input' )
.first()
.prop( 'disabled' )
).to.not.be.ok;
expect(
wrapper
.find( '.transaction-id-form__continue-button' )
.first()
.prop( 'disabled' )
).to.be.ok;
} );

test( 'should be disabled when continue button clicked', () => {
const wrapper = mount( <TransactionIdFormComponent className="test__test" /> );
wrapper.setState( { transactionId: 1 } );

wrapper.find( '.transaction-id-form__transaction-id-input' ).node.value = 'test';
wrapper.find( '.transaction-id-form__transaction-id-input' ).simulate( 'change' );
wrapper.find( '.transaction-id-form__continue-button' ).simulate( 'click' );

wrapper.find( 'button.transaction-id-form__continue-button' ).simulate( 'click' );
expect( wrapper ).to.have.state( 'isSubmitting' ).to.be.true;
expect( wrapper.find( '.transaction-id-form__transaction-id-input' ).prop( 'disabled' ) ).to
.be.ok;
expect( wrapper.find( '.transaction-id-form__continue-button' ).prop( 'disabled' ) ).to.be.ok;
expect(
wrapper
.find( '.transaction-id-form__transaction-id-input' )
.first()
.prop( 'disabled' )
).to.be.ok;
expect(
wrapper
.find( '.transaction-id-form__continue-button' )
.first()
.prop( 'disabled' )
).to.be.ok;
} );
} );
} );
2 changes: 2 additions & 0 deletions client/auth/test/login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ describe( 'LoginTest', () => {
test( 'cannot submit until login details entered', done => {
expect( page.find( FormButton ).props().disabled ).to.be.true;
page.setState( { login: 'test', password: 'test', inProgress: false }, function() {
page.update();
expect( page.find( FormButton ).props().disabled ).to.be.false;
done();
} );
} );

test( 'shows OTP box with valid login', done => {
page.setState( { login: 'test', password: 'test', requires2fa: true }, function() {
page.update();
expect( page.find( { name: 'auth_code' } ) ).to.have.length( 1 );
done();
} );
Expand Down
4 changes: 3 additions & 1 deletion client/blocks/image-editor/test/image-editor-canvas.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ describe( 'ImageEditorToolbar', () => {
let wrapper;

beforeEach( () => {
wrapper = shallow( <ImageEditorCanvas isImageLoaded={ true } /> );
wrapper = shallow( <ImageEditorCanvas isImageLoaded={ true } />, {
disableLifecycleMethods: true,
} );
} );

test( 'should render cropping area when the image meets the minimum height and width', () => {
Expand Down
4 changes: 2 additions & 2 deletions client/blocks/login/login-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class LoginForm extends Component {
componentDidMount() {
this.setState( { isDisabledWhileLoading: false }, () => {
// eslint-disable-line react/no-did-mount-set-state
this.usernameOrEmail.focus();
this.usernameOrEmail && this.usernameOrEmail.focus();
} );
}

Expand All @@ -84,7 +84,7 @@ export class LoginForm extends Component {
}

if ( requestError.field === 'usernameOrEmail' ) {
defer( () => this.usernameOrEmail.focus() );
defer( () => this.usernameOrEmail && this.usernameOrEmail.focus() );
}
}

Expand Down
6 changes: 3 additions & 3 deletions client/components/auto-direction/test/auto-direction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe( 'AutoDirection', () => {
</AutoDirection>
);

expect( wrapper.node.props.direction ).to.equal( 'rtl' );
expect( wrapper.getElement().props.direction ).to.equal( 'rtl' );
} );

test( "doesn't add a direction to LTR text", () => {
Expand All @@ -35,7 +35,7 @@ describe( 'AutoDirection', () => {
</AutoDirection>
);

expect( wrapper.node.props ).to.not.have.property( 'direction' );
expect( wrapper.getElement().props ).to.not.have.property( 'direction' );
} );

test( 'adds a direction to the parent of an inline component', () => {
Expand All @@ -47,7 +47,7 @@ describe( 'AutoDirection', () => {
</AutoDirection>
);

expect( wrapper.node.props.direction ).to.equal( 'rtl' );
expect( wrapper.getElement().props.direction ).to.equal( 'rtl' );

// Things get weird when mounting a stateless component, so just check for the HTML, instead.
expect( wrapper.html() ).to.include( '<div class="emojify">השנה היא 2017.</div>' );
Expand Down
Loading