[AAE-12065] improve tests

This commit is contained in:
Diogo Bastos 2023-07-24 16:58:38 +01:00
parent 94dae984a7
commit d861d17de3
No known key found for this signature in database
GPG Key ID: FE1461D16E03AEB3
2 changed files with 26 additions and 3 deletions

View File

@ -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)', () => {

View File

@ -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
}
]
];