97049: Nest before each statements

This commit is contained in:
Jens Vannerum
2023-01-02 14:38:20 +01:00
parent 6012c66d1c
commit 3e09653f0b

View File

@@ -87,10 +87,6 @@ describe('SearchHierarchyFilterComponent', () => {
showVocabularyTreeLink = fixture.debugElement.query(By.css('a#show-test-search-filter-tree')); showVocabularyTreeLink = fixture.debugElement.query(By.css('a#show-test-search-filter-tree'));
} }
afterEach(() => {
fixture.destroy();
});
describe('if the vocabulary doesn\'t exist', () => { describe('if the vocabulary doesn\'t exist', () => {
beforeEach(() => { beforeEach(() => {
@@ -100,9 +96,8 @@ describe('SearchHierarchyFilterComponent', () => {
init(); init();
}); });
it('should not show the vocabulary tree link', (done) => { it('should not show the vocabulary tree link', () => {
expect(showVocabularyTreeLink).toBeNull(); expect(showVocabularyTreeLink).toBeNull();
done();
}); });
}); });
@@ -115,39 +110,34 @@ describe('SearchHierarchyFilterComponent', () => {
init(); init();
}); });
it('should show the vocabulary tree link', (done) => { it('should show the vocabulary tree link', () => {
expect(showVocabularyTreeLink).toBeTruthy(); expect(showVocabularyTreeLink).toBeTruthy();
done();
}); });
describe('when clicking the vocabulary tree link', () => { describe('when clicking the vocabulary tree link', () => {
const alreadySelectedValues = [
'already-selected-value-1',
'already-selected-value-2',
];
const newSelectedValue = 'new-selected-value';
beforeEach(async () => { beforeEach(async () => {
showVocabularyTreeLink.nativeElement.click(); showVocabularyTreeLink.nativeElement.click();
fixture.componentInstance.selectedValues$ = observableOf(
alreadySelectedValues.map(value => Object.assign(new FacetValue(), { value }))
);
VocabularyTreeViewComponent.select.emit(Object.assign(new VocabularyEntryDetail(), {
value: newSelectedValue,
}));
}); });
it('should open the vocabulary tree modal', (done) => { it('should open the vocabulary tree modal', () => {
expect(ngbModal.open).toHaveBeenCalled(); expect(ngbModal.open).toHaveBeenCalled();
done();
}); });
describe('when selecting a value from the vocabulary tree', () => { describe('when selecting a value from the vocabulary tree', () => {
const alreadySelectedValues = [
'already-selected-value-1',
'already-selected-value-2',
];
const newSelectedValue = 'new-selected-value';
beforeEach(() => {
fixture.componentInstance.selectedValues$ = observableOf(
alreadySelectedValues.map(value => Object.assign(new FacetValue(), { value }))
);
VocabularyTreeViewComponent.select.emit(Object.assign(new VocabularyEntryDetail(), {
value: newSelectedValue,
}));
});
it('should add a new search filter to the existing search filters', () => { it('should add a new search filter to the existing search filters', () => {
waitForAsync(() => expect(router.navigate).toHaveBeenCalledWith([testSearchLink], { waitForAsync(() => expect(router.navigate).toHaveBeenCalledWith([testSearchLink], {
queryParams: { queryParams: {