Это мой date-formatter-by-timezone.pipe.ts
pipe
import { Pipe, PipeTransform } from '@angular/core';
import { CookieService } from 'ngx-cookie-service';
@Pipe({
name: 'dateFormatterSecByTimezone'
})
export class DateFormatterSecByTimezonePipe implements PipeTransform {
constructor(private cookieService: CookieService) {}
timezone:any = parseInt(this.cookieService.get('TM_Z')) * 1000;
caculateTime(date , timezone){
//some code here ...
}
transform(date: any){
return this.caculateTime(date , this.timezone)
}
}
И это spec-файл date-formatter-sec.pipe.spec.ts
:
import { DateFormatterSecByTimezonePipe } from './date-formatter-sec-by-
timezone.pipe';
describe('DateFormatterSecByTimezonePipe', () => {
it('create an instance', () => {
const pipe = new DateFormatterSecByTimezonePipe();
expect(pipe).toBeTruthy();
});
});
В spec-файле я получил эту ошибку:
Expected 1 argument, but got 0.
(alias) new DateFormatterSecByTimezonePipe(cookieService: CookieService):
DateFormatterSecByTimezonePipe
import DateFormatterSecByTimezonePipe
но когда я использую код выше, предложенный редактором, он все равно не работает!Я импортировал конструктор в свой канал, потому что мне нужно было использовать данные cookie в этом канале.Как я могу исправить эту ошибку?