From 1b13978d4d1ee85aaf09d092c3c8a021478244fc Mon Sep 17 00:00:00 2001 From: LvffY Date: Sat, 2 Apr 2022 17:19:33 +0200 Subject: [PATCH] =?UTF-8?q?[#10582]=20=F0=9F=92=9A=20Fix=20tests=20for=20t?= =?UTF-8?q?odo-backend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LvffY (cherry picked from commit eba6328126af2e20a429c96081ae96c4615a7c9d) --- .../src/service/TodoReaderService.test.ts | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/plugins/todo-backend/src/service/TodoReaderService.test.ts b/plugins/todo-backend/src/service/TodoReaderService.test.ts index 943462bd63..f99a9b7502 100644 --- a/plugins/todo-backend/src/service/TodoReaderService.test.ts +++ b/plugins/todo-backend/src/service/TodoReaderService.test.ts @@ -310,7 +310,7 @@ describe('TodoReaderService', () => { }); }); - it('should throw if entity does not have a location', async () => { + it('should not throw if entity does not have a location', async () => { const todoReader = mockTodoReader([]); const catalogClient = mockCatalogClient({ ...mockEntity, @@ -320,14 +320,14 @@ describe('TodoReaderService', () => { await expect(service.listTodos({ entity: entityName })).rejects.toEqual( expect.objectContaining({ - name: 'InputError', + name: 'Error', message: - 'No entity location annotation found for component:default/my-component', + 'Entity \'component:default/my-component\' is missing location', }), ); }); - it('should throw if entity has an invalid location', async () => { + it('should not throw if entity has an invalid location', async () => { const todoReader = mockTodoReader([]); const catalogClient = mockCatalogClient({ ...mockEntity, @@ -340,15 +340,16 @@ describe('TodoReaderService', () => { }); const service = new TodoReaderService({ todoReader, catalogClient }); - await expect(service.listTodos({ entity: entityName })).rejects.toEqual( - expect.objectContaining({ - name: 'InputError', - message: `Invalid entity location type for component:default/my-component, got 'file'`, - }), + await expect(service.listTodos({ entity: entityName })).resolves.toEqual({ + items: [], + totalCount: 0, + offset: 0, + limit: 10, + } ); }); - it('should throw if entity has an invalid source location', async () => { + it('should not throw if entity has an invalid source location', async () => { const todoReader = mockTodoReader([]); const catalogClient = mockCatalogClient({ ...mockEntity, @@ -361,11 +362,12 @@ describe('TodoReaderService', () => { }); const service = new TodoReaderService({ todoReader, catalogClient }); - await expect(service.listTodos({ entity: entityName })).rejects.toEqual( - expect.objectContaining({ - name: 'InputError', - message: `Invalid entity source location type for component:default/my-component, got 'file'`, - }), + await expect(service.listTodos({ entity: entityName })).resolves.toEqual({ + items: [], + totalCount: 0, + offset: 0, + limit: 10, + } ); }); });