From bc146480d29e8c5559b5db7fdb11180aca37e40b Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 20 Oct 2022 16:27:24 +0200 Subject: [PATCH] added test for new #hasFiles --- .../public/components/upload_file/upload_state.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/x-pack/plugins/files/public/components/upload_file/upload_state.test.ts b/x-pack/plugins/files/public/components/upload_file/upload_state.test.ts index 3a4e19adf8114..a834103a2c9cb 100644 --- a/x-pack/plugins/files/public/components/upload_file/upload_state.test.ts +++ b/x-pack/plugins/files/public/components/upload_file/upload_state.test.ts @@ -206,4 +206,14 @@ describe('UploadState', () => { expectObservable(uploadState.clear$, '^').toBe(' ---0-', [undefined]); }); }); + + it('correctly detects when files are ready for upload', () => { + const file1 = { name: 'test' } as File; + const file2 = { name: 'test 2.png' } as File; + expect(uploadState.hasFiles()).toBe(false); + uploadState.setFiles([file1, file2]); + expect(uploadState.hasFiles()).toBe(true); + uploadState.setFiles([]); + expect(uploadState.hasFiles()).toBe(false); + }); });