-
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.
- Loading branch information
1 parent
ec82855
commit 6ce57e3
Showing
2 changed files
with
42 additions
and
31 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
x-pack/plugins/lens/server/migrations/common_migrations.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,42 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { Filter } from '@kbn/es-query'; | ||
import { getLensFilterMigrations } from './common_migrations'; | ||
|
||
describe('Lens migrations', () => { | ||
describe('applying filter migrations', () => { | ||
it('creates a filter migrations map that works on a lens visualization', () => { | ||
const filterMigrations = { | ||
'1.1': (filter: Filter) => ({ ...filter, version: '1.1' }), | ||
'2.2': (filter: Filter) => ({ ...filter, version: '2.2' }), | ||
'3.3': (filter: Filter) => ({ ...filter, version: '3.3' }), | ||
}; | ||
|
||
const lensVisualization = { | ||
state: { | ||
filters: [{}, {}], | ||
}, | ||
}; | ||
|
||
const migrationMap = getLensFilterMigrations(filterMigrations); | ||
|
||
expect(migrationMap['1.1'](lensVisualization).state.filters).toEqual([ | ||
{ version: '1.1' }, | ||
{ version: '1.1' }, | ||
]); | ||
expect(migrationMap['2.2'](lensVisualization).state.filters).toEqual([ | ||
{ version: '2.2' }, | ||
{ version: '2.2' }, | ||
]); | ||
expect(migrationMap['3.3'](lensVisualization).state.filters).toEqual([ | ||
{ version: '3.3' }, | ||
{ version: '3.3' }, | ||
]); | ||
}); | ||
}); | ||
}); |
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