Skip to content

Commit 94293c2

Browse files
committed
fix tests
1 parent 3ad79cd commit 94293c2

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

x-pack/plugins/lens/public/persistence/saved_object_store.test.ts

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { SavedObjectsClientContract, SavedObjectsBulkUpdateObject } from 'kibana/public';
78
import { SavedObjectIndexStore } from './saved_object_store';
89

910
describe('LensStore', () => {
1011
function testStore(testId?: string) {
1112
const client = {
1213
create: jest.fn(() => Promise.resolve({ id: testId || 'testid' })),
13-
update: jest.fn((_type: string, id: string) => Promise.resolve({ id })),
14+
bulkUpdate: jest.fn(([{ id }]: SavedObjectsBulkUpdateObject[]) =>
15+
Promise.resolve({ savedObjects: [{ id }, { id }] })
16+
),
1417
get: jest.fn(),
1518
};
1619

1720
return {
1821
client,
19-
store: new SavedObjectIndexStore(client),
22+
store: new SavedObjectIndexStore((client as unknown) as SavedObjectsClientContract),
2023
};
2124
}
2225

@@ -108,19 +111,35 @@ describe('LensStore', () => {
108111
},
109112
});
110113

111-
expect(client.update).toHaveBeenCalledTimes(1);
112-
expect(client.update).toHaveBeenCalledWith('lens', 'Gandalf', {
113-
title: 'Even the very wise cannot see all ends.',
114-
visualizationType: 'line',
115-
expression: '',
116-
state: {
117-
datasourceMetaData: { filterableIndexPatterns: [] },
118-
datasourceStates: { indexpattern: { type: 'index_pattern', indexPattern: 'lotr' } },
119-
visualization: { gear: ['staff', 'pointy hat'] },
120-
query: { query: '', language: 'lucene' },
121-
filters: [],
114+
expect(client.bulkUpdate).toHaveBeenCalledTimes(1);
115+
expect(client.bulkUpdate).toHaveBeenCalledWith([
116+
{
117+
type: 'lens',
118+
id: 'Gandalf',
119+
attributes: {
120+
title: null,
121+
visualizationType: null,
122+
expression: null,
123+
state: null,
124+
},
122125
},
123-
});
126+
{
127+
type: 'lens',
128+
id: 'Gandalf',
129+
attributes: {
130+
title: 'Even the very wise cannot see all ends.',
131+
visualizationType: 'line',
132+
expression: '',
133+
state: {
134+
datasourceMetaData: { filterableIndexPatterns: [] },
135+
datasourceStates: { indexpattern: { type: 'index_pattern', indexPattern: 'lotr' } },
136+
visualization: { gear: ['staff', 'pointy hat'] },
137+
query: { query: '', language: 'lucene' },
138+
filters: [],
139+
},
140+
},
141+
},
142+
]);
124143
});
125144
});
126145

0 commit comments

Comments
 (0)