From 461c7b724075daabbc035d08d0a1451679b5ff79 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Wed, 1 Sep 2021 19:27:09 +0200 Subject: [PATCH] add exporter test --- .../export/saved_objects_exporter.test.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/core/server/saved_objects/export/saved_objects_exporter.test.ts b/src/core/server/saved_objects/export/saved_objects_exporter.test.ts index b3e40eaa19f9f..44e64c0f8c6b3 100644 --- a/src/core/server/saved_objects/export/saved_objects_exporter.test.ts +++ b/src/core/server/saved_objects/export/saved_objects_exporter.test.ts @@ -1316,5 +1316,43 @@ describe('getSortedObjectsForExport()', () => { } `); }); + + test(`uses the object's spaces when calling 'bulkGet' if present`, async () => { + savedObjectsClient.bulkGet.mockResolvedValueOnce({ + saved_objects: [], + }); + await exporter.exportByObjects({ + request, + objects: [ + { + type: 'index-pattern', + id: '1', + namespace: 'ns-1', + }, + { + type: 'search', + id: '2', + namespace: 'ns-2', + }, + ], + }); + + expect(savedObjectsClient.bulkGet).toHaveBeenCalledTimes(1); + expect(savedObjectsClient.bulkGet).toHaveBeenCalledWith( + [ + { + type: 'index-pattern', + id: '1', + namespaces: ['ns-1'], + }, + { + type: 'search', + id: '2', + namespaces: ['ns-2'], + }, + ], + {} + ); + }); }); });