When running the test for FilterComponent, I keep encountering this error:
Error
'Error during cleanup of component', Object{component: FilterComponent{lang:
Language{cookie: ..., get: ..., getLocale: ..., dict: ...}, api: Api{http:
..., router: ..., cookie: ..., send: ..., setUrl: ...}, filterService:
FilterService{update: ..., filter: ...}, searchbar: SearchbarService{},
localStorageCache: LocalStorageCache{api: ...}, cookie: CookieService{document:
..., optionsProvider: ..., cookieWriterService: ..., options: ...}, formatter:
NgbDateISOParserFormatter{}, calendar: NgbCalendarGregorian{}, onFilter:
EventEmitter{_isScalar: ..., observers: ..., closed: ..., isStopped: ..., hasError:
..., thrownError: ..., __isAsync: ...}, category: '', search: Subject{_isScalar:
..., observers: ..., closed: ..., isStopped: ..., hasError: ..., thrownError: ...},
selectedElems: [], hoveredDate: null, filterDef: Object{tweets: ..., news: ..., events:
..., dashboard: ..., dashboardHashtags: ..., people: ..., reports: ..., editorials:
..., verdicts: ..., organizations: ..., results: ..., _dashboard: ...}, componentDict:
Object{author: ..., people: ..., organizations: ..., tag: ..., tactics: ..., court:
..., pillars: ..., hashtags: ..., magistrates: ..., website: ...}, yearRange: [..., ...],
getPillars: () => { ... }, dateFromNgbDate: ngbDate => { ... }, isEmpty: () => { ... },
getElements: () => { ... }, addItem: item => { ... }, compareIds: (el1, el2) => { ... },
clearItem: item => { ... }, fillMultiSelect: () => { ... }, relevantChange: $ev => {
... }, user: Object{id: ..., username: ..., name: ..., role: ..., id_client: ...,
language: ..., filter: ..., services: ...}, __ngContext__: [..., ..., ..., ..., ...,
..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ...,
..., ..., ..., ..., ..., ..., ..., ..., ...], filterObj: Object{date_range: ...,
relevant: ...}}, stacktrace: TypeError: Cannot read properties of undefined (reading 'unsubscribe')
TypeError: Cannot read properties of undefined (reading 'unsubscribe')
I have made sure to import all necessary components in the spec file configuration.
filterComponent
import { Component, Input, Output, EventEmitter, OnInit, OnDestroy } from '@angular/core';
import { Language } from '../../services/language.service';
import { Observable, concat, of, Subject, Subscription } from 'rxjs';
import { distinctUntilChanged, switchMap, filter } from 'rxjs/operators';
import { CookieService } from 'ngx-cookie';
import { Api } from '../../services/api.service';
import { FilterService } from '../../services/filter.service';
import { LocalStorageCache } from '../../services/local-storage-cache.service';
import * as _ from 'lodash';
import { SearchbarService } from '../../services/searchbar.service';
import { NgbDate, NgbCalendar, NgbDateParserFormatter } from '@ng-bootstrap/ng-bootstrap';
export interface MultiSelectItem {
id: number,
name: string,
type: string
}
@Component({
selector: 'is-filter',
templateUrl: './filter.component.html',
styleUrls: ['./filter.component.scss']
})
export class FilterComponent implements OnInit, OnDestroy {
@Input() type: string;
@Input() filterObj: any;
@Output() onFilter: EventEmitter<any> = new EventEmitter<any>();
// Rest of the code goes here...
Despite importing and configuring everything needed in the ts file, the ng test command continues to fail. Help required.
SPEC:
// Test cases go here...