-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for getSelectedIdFromUrl and getGroupQueryText
- Loading branch information
1 parent
148ab2a
commit 3e9c17b
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { getGroupQueryText, getSelectedIdFromUrl } from './utils'; | ||
|
||
describe('ML - Jobs List utils', () => { | ||
const jobId = 'test_job_id_1'; | ||
const jobIdUrl = `http://localhost:5601/aql/app/ml#/jobs?mlManagement=(jobId:!(${jobId}))`; | ||
const groupIdOne = 'test_group_id_1'; | ||
const groupIdTwo = 'test_group_id_2'; | ||
const groupIdsUrl = `http://localhost:5601/aql/app/ml#/jobs?mlManagement=(groupIds:!(${groupIdOne},${groupIdTwo}))`; | ||
const groupIdUrl = `http://localhost:5601/aql/app/ml#/jobs?mlManagement=(groupIds:!(${groupIdOne}))`; | ||
|
||
describe('getSelectedIdFromUrl', () => { | ||
it('should get selected job id from the url', () => { | ||
const actual = getSelectedIdFromUrl(jobIdUrl); | ||
expect(actual).toStrictEqual({ ids: [jobId], isGroup: false }); | ||
}); | ||
|
||
it('should get selected group ids from the url', () => { | ||
const expected = { ids: [groupIdOne, groupIdTwo], isGroup: true }; | ||
const actual = getSelectedIdFromUrl(groupIdsUrl); | ||
expect(actual).toStrictEqual(expected); | ||
}); | ||
|
||
it('should get selected group id from the url', () => { | ||
const expected = { ids: [groupIdOne], isGroup: true }; | ||
const actual = getSelectedIdFromUrl(groupIdUrl); | ||
expect(actual).toStrictEqual(expected); | ||
}); | ||
}); | ||
|
||
describe('getGroupQueryText', () => { | ||
it('should get query string for selected group ids', () => { | ||
const actual = getGroupQueryText([groupIdOne, groupIdTwo]); | ||
expect(actual).toBe(`groups:(${groupIdOne} or ${groupIdTwo})`); | ||
}); | ||
|
||
it('should get query string for selected group id', () => { | ||
const actual = getGroupQueryText([groupIdOne]); | ||
expect(actual).toBe(`groups:(${groupIdOne})`); | ||
}); | ||
}); | ||
}); |