<commit_before>import React from 'react';
import { shallow } from 'enzyme';
import { Message } from 'retranslate';
import { LoginPage } from './LoginPage';
import { AuthenticationLoader } from '../common';
import ErrorAlert from './errorAlert';
import LoginForm from './loginForm';

describe('Login page', () => {
  let props;
  let component;

  beforeEach(() => {
    props = {};
    component = shallow(<LoginPage {...props} />);
  });

  it('renders some messages', () => {
    expect(component.contains(<Message>login.title</Message>)).toBe(true);
  });

  it('renders a login form if no actions have not been taken', () => {
    const formProps = {
      phoneNumber: 'number',
      onPhoneNumberChange: jest.fn(),
      onPhoneNumberSubmit: jest.fn(),
    };
    component.setProps(formProps);
    expect(component.contains(<LoginForm {...formProps} />)).toBe(true);
  });

  it('renders an authentication loader instead if loading or has control code', () => {
    const onCancelMobileAuthentication = jest.fn();
    component.setProps({ onCancelMobileAuthentication });

    expect(component.contains(
      <AuthenticationLoader controlCode="" onCancel={onCancelMobileAuthentication} />,
    )).toBe(false);
    component.setProps({ loadingControlCode: true });
    expect(component.contains(
      <AuthenticationLoader controlCode="" onCancel={onCancelMobileAuthentication} />,
    )).toBe(true);
    component.setProps({ controlCode: '1337' });
    expect(component.contains(
      <AuthenticationLoader controlCode="1337" onCancel={onCancelMobileAuthentication} />,<commit_msg>Fix loginPage test<commit_after>import React from 'react';
import { shallow } from 'enzyme';
import { Message } from 'retranslate';
import { LoginPage } from './LoginPage';
import { AuthenticationLoader } from '../common';
import ErrorAlert from './errorAlert';
import LoginForm from './loginForm';

describe('Login page', () => {
  let props;
  let component;

  beforeEach(() => {
    props = {};
    component = shallow(<LoginPage {...props} />);
  });

  it('renders some messages', () => {
    expect(component.contains(<Message>login.not.member</Message>)).toBe(true);
  });

  it('renders a login form if no actions have not been taken', () => {
    const formProps = {
      phoneNumber: 'number',
      onPhoneNumberChange: jest.fn(),
      onPhoneNumberSubmit: jest.fn(),
    };
    component.setProps(formProps);
    expect(component.contains(<LoginForm {...formProps} />)).toBe(true);
  });

  it('renders an authentication loader instead if loading or has control code', () => {
    const onCancelMobileAuthentication = jest.fn();
    component.setProps({ onCancelMobileAuthentication });

    expect(component.contains(
      <AuthenticationLoader controlCode="" onCancel={onCancelMobileAuthentication} />,
    )).toBe(false);
    component.setProps({ loadingControlCode: true });
    expect(component.contains(
      <AuthenticationLoader controlCode="" onCancel={onCancelMobileAuthentication} />,
    )).toBe(true);
    component.setProps({ controlCode: '1337' });
    expect(component.contains(
      <AuthenticationLoader controlCode="1337" onCancel={onCancelMobileAuthentication} />,
{'fraction_non_alphanumeric': 0.15184721352536004, 'fraction_numerical': 0.005009392611145898, 'mean_word_length': 4.254934210526316, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, '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': '6617153', 'n_tokens_mistral': 876, 'n_tokens_neox': 843, 'n_words': 206}