Sha256: 614f926eab010ce20584361eed62844927315598da39f050815ee5236f8a0ee2

Contents?: true

Size: 1.73 KB

Versions: 22

Compression:

Stored size: 1.73 KB

Contents

import React from 'react';
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
import { shallow } from 'enzyme';

import { getQueryKeyText, getQueryValueText } from '../../TasksDashboardHelper';
import TasksLabelsRow from './TasksLabelsRow';

jest.mock('../../TasksDashboardHelper');

getQueryKeyText.mockImplementation(val => val);
getQueryValueText.mockImplementation(val => val);

const fixtures = {
  'render with minimal props': {},
  'render with props': {
    query: { some: 'query' },
    updateQuery: jest.fn(),
  },
};

describe('TasksLabelsRow', () => {
  describe('rendering', () =>
    testComponentSnapshotsWithFixtures(TasksLabelsRow, fixtures));

  describe('triggering', () => {
    it('should trigger updateQuery when label delete-click', () => {
      const updateQuery = jest.fn();
      const query = { some: 'query', someOther: 'some-query' };

      const component = shallow(
        <TasksLabelsRow query={query} updateQuery={updateQuery} />
      );
      const labels = component.find('Label');

      const firstLabel = labels.first();
      const secondLabel = labels.at(1);

      firstLabel.simulate('removeClick');
      expect(updateQuery).toHaveBeenCalledWith({ someOther: 'some-query' });

      secondLabel.simulate('removeClick');
      expect(updateQuery).toHaveBeenCalledWith({ some: 'query' });
    });

    it('should trigger updateQuery when -clear-all- click', () => {
      const updateQuery = jest.fn();
      const query = { some: 'query', someOther: 'some-query' };

      const component = shallow(
        <TasksLabelsRow query={query} updateQuery={updateQuery} />
      );
      component.find('Button').simulate('click');

      expect(updateQuery).toHaveBeenCalledWith({});
    });
  });
});

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
foreman-tasks-0.17.6 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-1.0.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.17.5 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.17.4 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.17.3 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.17.2 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.16.3 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.17.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.15.11 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.16.2 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.15.10 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.16.1 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.17.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.15.9 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.15.8 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.15.7 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.16.0 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.15.6 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.15.5 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
foreman-tasks-0.15.4 webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js