<commit_before>import { mount } from '@vue/test-utils';
import store from 'kolibri.coreVue.vuex.store';
import UiIcon from 'kolibri-design-system/lib/keen/UiIcon';
import ProgressIcon from '../src/views/ProgressIcon';

function testIcon(wrapper, expectedText) {
  expect(
    wrapper
      .find({ name: 'KTooltip' })
      .text()
      .trim()
  ).toEqual(expectedText);
}

describe('ProgressIcon Component', () => {
  it('should be empty when progress is < 0', async () => {
    const wrapper = mount(ProgressIcon, {
      propsData: {
        // Causes a validation error
        progress: -1.0,
      },
      store,
    });
    await wrapper.vm.$nextTick();
    const tooltip = wrapper.find({ name: 'KTooltip' });
    expect(wrapper.contains(UiIcon)).toEqual(false);
    // Tooltip is still around, just nothing to trigger it.
    expect(tooltip.text().trim()).toEqual('Completed');
  });

  it('it should show an in-progress icon when progress is between 0 and 1', async () => {
    const wrapper = mount(ProgressIcon, {
      propsData: {
        progress: 0.1,
      },
      store,
    });
    await wrapper.vm.$nextTick();
    testIcon(wrapper, 'In progress');
  });

  it('it should show a completed icon when progress is exactly 1', async () => {
    const wrapper = mount(ProgressIcon, {
      propsData: {
        progress: 1.0,
      },
      store,
    });
    await wrapper.vm.$nextTick();
    testIcon(wrapper, 'Completed');
  });

  it('it should show a completed icon when progress is greater than 1', async () => {
    const wrapper = mount(ProgressIcon, {
      propsData: {
        progress: 2.0,<commit_msg>Upgrade ProgressIcon specs<commit_after>import { mount } from '@vue/test-utils';
import store from 'kolibri.coreVue.vuex.store';
import UiIcon from 'kolibri-design-system/lib/keen/UiIcon';
import ProgressIcon from '../src/views/ProgressIcon';

function testIcon(wrapper, expectedText) {
  expect(
    wrapper
      .findComponent({ name: 'KTooltip' })
      .text()
      .trim()
  ).toEqual(expectedText);
}

describe('ProgressIcon Component', () => {
  it('should be empty when progress is < 0', async () => {
    const wrapper = mount(ProgressIcon, {
      propsData: {
        // Causes a validation error
        progress: -1.0,
      },
      store,
    });
    await wrapper.vm.$nextTick();
    const tooltip = wrapper.findComponent({ name: 'KTooltip' });
    expect(wrapper.findComponent(UiIcon).element).toBeFalsy();
    // Tooltip is still around, just nothing to trigger it.
    expect(tooltip.text().trim()).toEqual('Completed');
  });

  it('it should show an in-progress icon when progress is between 0 and 1', async () => {
    const wrapper = mount(ProgressIcon, {
      propsData: {
        progress: 0.1,
      },
      store,
    });
    await wrapper.vm.$nextTick();
    testIcon(wrapper, 'In progress');
  });

  it('it should show a completed icon when progress is exactly 1', async () => {
    const wrapper = mount(ProgressIcon, {
      propsData: {
        progress: 1.0,
      },
      store,
    });
    await wrapper.vm.$nextTick();
    testIcon(wrapper, 'Completed');
  });

  it('it should show a completed icon when progress is greater than 1', async () => {
    const wrapper = mount(ProgressIcon, {
      propsData: {
        progress: 2.0,
{'fraction_non_alphanumeric': 0.1443267776096823, 'fraction_numerical': 0.007866868381240545, 'mean_word_length': 2.826388888888889, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '3946071', 'n_tokens_mistral': 992, 'n_tokens_neox': 985, 'n_words': 269}