#860 Update Derivation of Wording on Reset / SelectAll Button

This commit is contained in:
Sebastian
2020-07-21 21:09:22 +02:00
parent 685e401e2d
commit 4d2d653cfa
4 changed files with 185 additions and 1 deletions

View File

@@ -0,0 +1,58 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SelectFilterComponent } from './select-filter.component';
import { SelectFilterOptionComponent } from './select-filter-option.component';
import {
selectFilterOptionsAllSelected,
selectFilterOptionsAllDeselected,
selectFilterOptionsMixedSelected,
} from '../../../../shelf/shared/mockdata';
import { NO_ERRORS_SCHEMA } from '@angular/core';
fdescribe('SelectFilterComponent', () => {
let fixture: ComponentFixture<SelectFilterComponent>;
let component: SelectFilterComponent;
beforeEach(async () => {
TestBed.configureTestingModule({
providers: [],
declarations: [SelectFilterComponent, SelectFilterOptionComponent],
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SelectFilterComponent);
component = fixture.componentInstance;
spyOn(component, 'ngAfterViewInit').and.callFake(() => {});
fixture.detectChanges();
});
describe('setAllSelected', () => {
beforeEach(() => {
spyOn(component, 'setAllSelected').and.callThrough();
spyOn(component.allSelected$, 'next').and.callFake(() => {});
});
it('should set allSelected with true', () => {
const mockFilters = selectFilterOptionsAllSelected;
component.setAllSelected(mockFilters);
expect(component.allSelected$.next).toHaveBeenCalledWith(true);
});
it('should set allSelected to false if only some options are selected', () => {
const mockFilters = selectFilterOptionsMixedSelected;
component.setAllSelected(mockFilters);
expect(component.allSelected$.next).toHaveBeenCalledWith(false);
});
it('should set allSelected with false', () => {
const mockFilters = selectFilterOptionsAllDeselected;
component.setAllSelected(mockFilters);
expect(component.allSelected$.next).toHaveBeenCalledWith(false);
});
});
});

View File

@@ -146,7 +146,7 @@ export class SelectFilterComponent
}
return options.every((option) => {
if (!option.options) {
if (!option.options || !option.options.length) {
return option.selected;
}

View File

@@ -2,4 +2,5 @@
export * from './historyDto.mock';
export * from './filters.mock';
export * from './primary-filters.mock';
export * from './select-filter-option.mock';
// end:ng42.barrel

View File

@@ -0,0 +1,125 @@
import { SelectFilterOption } from '../../../filter';
export const selectFilterOptionsAllDeselected: SelectFilterOption[] = [
{
name: 'abgeholt',
id: '256',
selected: false,
initial_selected_state: false,
expanded: false,
},
{
name: 'angefragt',
id: '524288',
selected: false,
initial_selected_state: false,
expanded: false,
},
{
name: 'ans Lager (nicht abgeholt)',
id: '262144',
selected: false,
initial_selected_state: false,
expanded: false,
},
{
name: 'bestellt',
id: '16',
selected: false,
initial_selected_state: true,
expanded: false,
},
{
name: 'derzeit nicht lieferbar',
id: '16777216',
selected: false,
initial_selected_state: false,
expanded: false,
},
{
name: 'eingetroffen',
id: '128',
selected: false,
initial_selected_state: true,
expanded: false,
},
{
name: 'Lieferant wird ermittelt',
id: '8388608',
selected: false,
initial_selected_state: false,
expanded: false,
},
{
name: 'nachbestellt',
id: '8192',
selected: false,
initial_selected_state: true,
expanded: false,
},
{
name: 'neu',
id: '1',
selected: false,
initial_selected_state: false,
expanded: false,
},
{
name: 'nicht lieferbar',
id: '4096',
selected: false,
initial_selected_state: false,
expanded: false,
},
{
name: 'storniert',
id: '1024',
selected: false,
initial_selected_state: true,
expanded: false,
},
{
name: 'storniert (Kunde)',
id: '512',
selected: false,
initial_selected_state: true,
expanded: false,
},
{
name: 'storniert (Lieferant)',
id: '2048',
selected: false,
initial_selected_state: true,
expanded: false,
},
{
name: 'versendet',
id: '64',
selected: false,
initial_selected_state: false,
expanded: false,
},
{
name: 'weitergeleitet intern',
id: '1048576',
selected: false,
initial_selected_state: false,
expanded: false,
},
{
name: 'zugestellt',
id: '4194304',
selected: false,
initial_selected_state: false,
expanded: false,
},
];
export const selectFilterOptionsAllSelected: SelectFilterOption[] = selectFilterOptionsAllDeselected.map(
(o) => ({ ...o, selected: true })
);
export const selectFilterOptionsMixedSelected: SelectFilterOption[] = selectFilterOptionsAllDeselected.map(
(o, index) =>
index % 2 ? { ...o, selected: true } : { ...o, selected: false }
);