forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed unused params and added jest test
- Loading branch information
1 parent
4050ae1
commit 7558ab8
Showing
3 changed files
with
117 additions
and
22 deletions.
There are no files selected for viewing
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,105 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { VisualizeLocatorDefinition } from './locator'; | ||
import { esFilters } from '../../data/public'; | ||
|
||
describe('visualize locator', () => { | ||
let definition: VisualizeLocatorDefinition; | ||
|
||
beforeEach(() => { | ||
definition = new VisualizeLocatorDefinition(); | ||
}); | ||
|
||
it('returns a location for "create" path', async () => { | ||
const location = await definition.getLocation({}); | ||
|
||
expect(location.app).toMatchInlineSnapshot(`"visualize"`); | ||
expect(location.path).toMatchInlineSnapshot(`"#/create?_g=()&_a=()"`); | ||
expect(location.state).toMatchInlineSnapshot(`Object {}`); | ||
}); | ||
|
||
it('returns a location for "edit" path', async () => { | ||
const location = await definition.getLocation({ visId: 'test', type: 'test' }); | ||
|
||
expect(location.app).toMatchInlineSnapshot(`"visualize"`); | ||
expect(location.path).toMatchInlineSnapshot(`"#/edit/test?type=test&_g=()&_a=()"`); | ||
expect(location.state).toMatchInlineSnapshot(`Object {}`); | ||
}); | ||
|
||
it('creates a location with query, filters (global and app), refresh interval and time range', async () => { | ||
const location = await definition.getLocation({ | ||
visId: '123', | ||
type: 'test', | ||
timeRange: { to: 'now', from: 'now-15m', mode: 'relative' }, | ||
refreshInterval: { pause: false, value: 300 }, | ||
filters: [ | ||
{ | ||
meta: { | ||
alias: null, | ||
disabled: false, | ||
negate: false, | ||
}, | ||
query: { query: 'hi' }, | ||
}, | ||
{ | ||
meta: { | ||
alias: null, | ||
disabled: false, | ||
negate: false, | ||
}, | ||
query: { query: 'hi' }, | ||
$state: { | ||
store: esFilters.FilterStateStore.GLOBAL_STATE, | ||
}, | ||
}, | ||
], | ||
query: { query: 'bye', language: 'kuery' }, | ||
}); | ||
|
||
expect(location.app).toMatchInlineSnapshot(`"visualize"`); | ||
|
||
expect(location.path.match(/filters:/g)?.length).toBe(2); | ||
expect(location.path.match(/refreshInterval:/g)?.length).toBe(1); | ||
expect(location.path.match(/time:/g)?.length).toBe(1); | ||
expect(location.path).toMatchInlineSnapshot( | ||
`"#/edit/123?type=test&_g=(filters:!(('$state':(store:globalState),meta:(alias:!n,disabled:!f,negate:!f),query:(query:hi))),refreshInterval:(pause:!f,value:300),time:(from:now-15m,mode:relative,to:now))&_a=(filters:!((meta:(alias:!n,disabled:!f,negate:!f),query:(query:hi))),query:(language:kuery,query:bye))"` | ||
); | ||
|
||
expect(location.state).toMatchInlineSnapshot(`Object {}`); | ||
}); | ||
|
||
it('creates a location with all values provided', async () => { | ||
const location = await definition.getLocation({ | ||
visId: '123', | ||
type: 'test', | ||
timeRange: { to: 'now', from: 'now-15m', mode: 'relative' }, | ||
refreshInterval: { pause: false, value: 300 }, | ||
filters: [ | ||
{ | ||
meta: { | ||
alias: null, | ||
disabled: false, | ||
negate: false, | ||
}, | ||
query: { query: 'hi' }, | ||
}, | ||
], | ||
query: { query: 'bye', language: 'kuery' }, | ||
linked: true, | ||
uiState: { fakeUIState: 'fakeUIState' }, | ||
vis: { fakeVis: 'fakeVis' }, | ||
}); | ||
|
||
expect(location.app).toMatchInlineSnapshot(`"visualize"`); | ||
expect(location.path).toMatchInlineSnapshot( | ||
`"#/edit/123?type=test&_g=(filters:!(),refreshInterval:(pause:!f,value:300),time:(from:now-15m,mode:relative,to:now))&_a=(filters:!((meta:(alias:!n,disabled:!f,negate:!f),query:(query:hi))),linked:!t,query:(language:kuery,query:bye),uiState:(fakeUIState:fakeUIState),vis:(fakeVis:fakeVis))"` | ||
); | ||
expect(location.state).toMatchInlineSnapshot(`Object {}`); | ||
}); | ||
}); |
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
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