|
4 | 4 | * you may not use this file except in compliance with the Elastic License. |
5 | 5 | */ |
6 | 6 |
|
| 7 | +import { SavedObjectsClientContract, SavedObjectsBulkUpdateObject } from 'kibana/public'; |
7 | 8 | import { SavedObjectIndexStore } from './saved_object_store'; |
8 | 9 |
|
9 | 10 | describe('LensStore', () => { |
10 | 11 | function testStore(testId?: string) { |
11 | 12 | const client = { |
12 | 13 | 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 | + ), |
14 | 17 | get: jest.fn(), |
15 | 18 | }; |
16 | 19 |
|
17 | 20 | return { |
18 | 21 | client, |
19 | | - store: new SavedObjectIndexStore(client), |
| 22 | + store: new SavedObjectIndexStore((client as unknown) as SavedObjectsClientContract), |
20 | 23 | }; |
21 | 24 | } |
22 | 25 |
|
@@ -108,19 +111,35 @@ describe('LensStore', () => { |
108 | 111 | }, |
109 | 112 | }); |
110 | 113 |
|
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 | + }, |
122 | 125 | }, |
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 | + ]); |
124 | 143 | }); |
125 | 144 | }); |
126 | 145 |
|
|
0 commit comments