From d861d17de34497f8e604a323d6f32c25cb4041f2 Mon Sep 17 00:00:00 2001 From: Diogo Bastos Date: Mon, 24 Jul 2023 16:58:38 +0100 Subject: [PATCH] [AAE-12065] improve tests --- .../dropdown/dropdown-cloud.widget.spec.ts | 12 +++++++++--- .../src/lib/form/mocks/dropdown.mock.ts | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts index 5f46e31ee6..824918266a 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts @@ -786,23 +786,29 @@ describe('DropdownCloudWidgetComponent', () => { expect(call).toEqual(undefined); }); - it('should get default option from list of options which have any id matching the DEFAULT_OPTION id, while not having an isDefault flag set to true', () => { + it('should get default option from list of options which has an id matching the DEFAULT_OPTION id, while not having an isDefault flag on that option', () => { const call = widget.getDefaultOption(fakeFormOptionEntries[1]); expect(call).toEqual(fakeFormOptionEntries[1][0]); }); - it('should get default option from list of options which have any id matching the DEFAULT_OPTION id while also having an isDefault flag set to true', () => { + it('should get default option from list of options which has an id matching the DEFAULT_OPTION id while also having an isDefault flag set to true on that option', () => { const call = widget.getDefaultOption(fakeFormOptionEntries[2]); expect(call).toEqual(fakeFormOptionEntries[2][0]); }); - it('should get default option from list of options which has an isDefault flag set to true, despite the option id', () => { + it('should get default option from list of options which has an isDefault flag set to true, despite the option id not matching the DEFAULT_OPTION id', () => { const call = widget.getDefaultOption(fakeFormOptionEntries[3]); expect(call).toEqual(fakeFormOptionEntries[3][0]); }); + + it('should not get default option from list of options which has an id matching the DEFAULT_OPTION id, while having an isDefault flag set to false on that option', () => { + const call = widget.getDefaultOption(fakeFormOptionEntries[4]); + + expect(call).toEqual(undefined); + }); }); describe('Load selection for linked dropdown (i.e. saved, completed forms)', () => { diff --git a/lib/process-services-cloud/src/lib/form/mocks/dropdown.mock.ts b/lib/process-services-cloud/src/lib/form/mocks/dropdown.mock.ts index bbf781d621..01e85a1bd0 100644 --- a/lib/process-services-cloud/src/lib/form/mocks/dropdown.mock.ts +++ b/lib/process-services-cloud/src/lib/form/mocks/dropdown.mock.ts @@ -230,6 +230,23 @@ export const fakeFormOptionEntries = [ name: 'name_3', isDefault: false } + ], + [ + { + id: 'empty', + name: 'name_1', + isDefault: false + }, + { + id: 'id_1', + name: 'name_2', + isDefault: false + }, + { + id: 'id_3', + name: 'name_3', + isDefault: false + } ] ];