<commit_before>import { shallow } from 'enzyme';
import * as React from 'react';
import * as Table from 'react-bootstrap/lib/Table';

import { translate } from '@waldur/i18n';
import { PureOpenstackInstanceCheckoutSummary } from '@waldur/openstack/openstack-instance/OpenstackInstanceCheckoutSummary';
import { summaryData as dataWithoutFlavor, flavor } from '@waldur/openstack/openstack-instance/storyFixtures';
import { QuotaUsageBarChart } from '@waldur/quotas/QuotaUsageBarChart';

jest.mock('@waldur/core/services', () => ({
  defaultCurrency: val => val,
  $sanitize: val => val,
}));

const renderWrapper = props =>
  shallow(
    (
      <PureOpenstackInstanceCheckoutSummary
        loading={false}
        loaded={true}
        translate={translate}
        {...props}
      />
    )
  );

describe('OpenstackInstanceCheckoutSummary', () => {
  const dataWithFlavor = {...dataWithoutFlavor, formData: {...dataWithoutFlavor.formData, flavor}};

  it('should render right message if no flavor has been selected', () => {
    const wrapper = renderWrapper(dataWithoutFlavor);
    expect(wrapper.find('p#invalid-info').text()).toContain('Please select flavor to see price estimate.');
    expect(wrapper.find('p#invalid-info').text()).not.toContain('Resource configuration is invalid. Please fix errors in form.');
  });

  it('should render right message if resource configuration is valid', () => {
    const wrapper = renderWrapper(dataWithFlavor);
    expect(wrapper.find('p#invalid-info').text()).not.toContain('Resource configuration is invalid. Please fix errors in form.');
  });

  it('should render Table and QuotaUsageBarChart if flavor has been selected', () => {
    const wrapper = renderWrapper(dataWithFlavor);
    expect(wrapper.find('p#invalid-info')).toHaveLength(0);
    expect(wrapper.find(Table)).toHaveLength(1);
    expect(wrapper.find(QuotaUsageBarChart)).toHaveLength(1);
  });
});<commit_msg>Fix test.<commit_after>import { shallow } from 'enzyme';
import * as React from 'react';
import * as Table from 'react-bootstrap/lib/Table';

import { translate } from '@waldur/i18n';
import { PureOpenstackInstanceCheckoutSummary } from '@waldur/openstack/openstack-instance/OpenstackInstanceCheckoutSummary';
import { summaryData as dataWithoutFlavor, flavor } from '@waldur/openstack/openstack-instance/storyFixtures';
import { QuotaUsageBarChart } from '@waldur/quotas/QuotaUsageBarChart';

jest.mock('@waldur/core/services', () => ({
  defaultCurrency: val => val,
  $sanitize: val => val,
}));

const renderWrapper = props =>
  shallow(
    (
      <PureOpenstackInstanceCheckoutSummary
        loading={false}
        loaded={true}
        translate={translate}
        {...props}
      />
    )
  );

describe('OpenstackInstanceCheckoutSummary', () => {
  const dataWithFlavor = {...dataWithoutFlavor, formData: {...dataWithoutFlavor.formData, flavor}};

  it('should render right message if no flavor has been selected', () => {
    const wrapper = renderWrapper(dataWithoutFlavor);
    expect(wrapper.find('p#invalid-info').text()).toContain('Please select flavor to see price estimate.');
    expect(wrapper.find('p#invalid-info').text()).not.toContain('Resource configuration is invalid. Please fix errors in form.');
  });

  it('should render right message if resource configuration is valid', () => {
    const wrapper = renderWrapper(dataWithFlavor);
    expect(wrapper.find('p#invalid-info')).toHaveLength(0);
  });

  it('should render Table and QuotaUsageBarChart if flavor has been selected', () => {
    const wrapper = renderWrapper(dataWithFlavor);
    expect(wrapper.find('p#invalid-info')).toHaveLength(0);
    expect(wrapper.find(Table)).toHaveLength(1);
    expect(wrapper.find(QuotaUsageBarChart)).toHaveLength(1);
  });
});
{'fraction_non_alphanumeric': 0.1438029661016949, 'fraction_numerical': 0.002913135593220339, 'mean_word_length': 4.6968325791855206, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '3405157', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1080, 'n_words': 237}