Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
ashokaditya committed Sep 20, 2022
1 parent 4a8b6f5 commit df009ca
Showing 1 changed file with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { actionsLogFiltersFromUrlParams } from './use_action_history_url_params';

describe('#actionsLogFiltersFromUrlParams', () => {
it('should not use invalid command values to URL params', () => {
it('should not use invalid command values from URL params', () => {
expect(actionsLogFiltersFromUrlParams({ commands: 'asa,was' })).toEqual({
commands: undefined,
endDate: undefined,
Expand All @@ -18,7 +18,7 @@ describe('#actionsLogFiltersFromUrlParams', () => {
});
});

it('should use valid command values to URL params', () => {
it('should use valid command values from URL params', () => {
expect(
actionsLogFiltersFromUrlParams({
commands: 'kill-process,isolate,processes,release,suspend-process',
Expand All @@ -33,7 +33,7 @@ describe('#actionsLogFiltersFromUrlParams', () => {
});
});

it('should not use invalid status values to URL params', () => {
it('should not use invalid status values from URL params', () => {
expect(actionsLogFiltersFromUrlParams({ statuses: 'asa,was' })).toEqual({
commands: undefined,
endDate: undefined,
Expand All @@ -44,7 +44,7 @@ describe('#actionsLogFiltersFromUrlParams', () => {
});
});

it('should use valid status values to URL params', () => {
it('should use valid status values from URL params', () => {
expect(
actionsLogFiltersFromUrlParams({
statuses: 'successful,pending,failed',
Expand All @@ -59,23 +59,27 @@ describe('#actionsLogFiltersFromUrlParams', () => {
});
});

it('should use valid command and status values to URL params', () => {
it('should use valid command and status along with given host, user and date values from URL params', () => {
expect(
actionsLogFiltersFromUrlParams({
commands: 'release,kill-process,isolate,processes,suspend-process',
statuses: 'successful,pending,failed',
hosts: 'host-1,host-2',
users: 'user-1,user-2',
startDate: '2022-09-12T08:00:00.000Z',
endDate: '2022-09-12T08:30:33.140Z',
})
).toEqual({
commands: ['isolate', 'kill-process', 'processes', 'release', 'suspend-process'],
endDate: undefined,
hosts: undefined,
startDate: undefined,
endDate: '2022-09-12T08:30:33.140Z',
hosts: ['host-1', 'host-2'],
startDate: '2022-09-12T08:00:00.000Z',
statuses: ['failed', 'pending', 'successful'],
users: undefined,
users: ['user-1', 'user-2'],
});
});

it('should use set given relative startDate and endDate values to URL params', () => {
it('should use given relative startDate and endDate values URL params', () => {
expect(
actionsLogFiltersFromUrlParams({
startDate: 'now-24h/h',
Expand All @@ -91,7 +95,7 @@ describe('#actionsLogFiltersFromUrlParams', () => {
});
});

it('should use set given absolute startDate and endDate values to URL params', () => {
it('should use given absolute startDate and endDate values URL params', () => {
expect(
actionsLogFiltersFromUrlParams({
startDate: '2022-09-12T08:00:00.000Z',
Expand All @@ -107,7 +111,7 @@ describe('#actionsLogFiltersFromUrlParams', () => {
});
});

it('should use set given hosts values to URL params', () => {
it('should use given hosts values from URL params', () => {
expect(
actionsLogFiltersFromUrlParams({
hosts: 'agent-id-1,agent-id-2',
Expand All @@ -121,4 +125,19 @@ describe('#actionsLogFiltersFromUrlParams', () => {
users: undefined,
});
});

it('should use given users values from URL params', () => {
expect(
actionsLogFiltersFromUrlParams({
users: 'usernameA,usernameB',
})
).toEqual({
commands: undefined,
endDate: undefined,
hosts: undefined,
startDate: undefined,
statuses: undefined,
users: ['usernameA', 'usernameB'],
});
});
});

0 comments on commit df009ca

Please sign in to comment.