Sha256: 3adf1128d9feedc5982690303ca109b2c549f417a5130e3a85875af258c3c85c

Contents?: true

Size: 1.5 KB

Versions: 47

Compression:

Stored size: 1.5 KB

Contents

import { updateURlQuery, getDuration, getCSVurl } from '../TasksTableHelpers';

describe('updateURlQuery', () => {
  it('should use url with new query', () => {
    const history = {
      push: jest.fn(),
      location: {
        pathname:
          '/foreman_tasks/tasks/?state=stopped&result=error&page=1&per_page=20',
      },
    };
    const query = { time_mode: 'recent', per_page: 35 };
    updateURlQuery(query, history);
    const newURL =
      '?state=stopped&result=error&page=1&per_page=35&time_mode=recent';
    expect(history.push).toBeCalledWith(newURL);
  });
  it('getDuration should work', () => {
    const duration = getDuration('1/1/2000 11:00', '1/1/2000 11:25');
    expect(duration.text).toEqual('25 minutes');
    expect(duration.tooltip).toEqual(undefined);
  });
  it('getDuration should work without start date', () => {
    const duration = getDuration('', '1/1/2000 11:25');
    expect(duration.text).toEqual('N/A');
    expect(duration.tooltip).toEqual('Task was canceled');
  });
});

describe('getCSVurl', () => {
  it('should return currect url for tasks with search', () => {
    const url = '/foreman_tasks/tasks';
    const query = { state: 'stopped' };
    expect(getCSVurl(url, query)).toEqual(
      '/foreman_tasks/tasks.csv?search=%28state%3Dstopped%29'
    );
  });
  it('should return currect url for subtasks', () => {
    const url = '/foreman_tasks/tasks/some-id/sub_tasks';
    expect(getCSVurl(url, {})).toEqual(
      '/foreman_tasks/tasks/some-id/sub_tasks.csv'
    );
  });
});

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
foreman-tasks-10.0.2 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-10.0.1 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-10.0.0 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-9.2.3 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-9.2.2 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-9.2.1 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-9.2.0 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-9.1.1 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-9.0.4 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-9.1.0 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-9.0.2 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-9.0.1 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-8.3.3 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-9.0.0 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-8.2.1 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-8.1.4 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-8.3.2 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-8.3.1 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-8.1.3 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js
foreman-tasks-8.3.0 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js