angular-calendar icon indicating copy to clipboard operation
angular-calendar copied to clipboard

unit testing: calendar-date.pipe error

Open prajwal-unext opened this issue 3 years ago • 2 comments

Describe the bug

When attempting to unit test a component that consumes angular-calendar. we get an error regarding the import.

Minimal reproduction of the problem with instructions This is how I have currently setup my testbed.

beforeEach(() => {
  TestBed.configureTestingModule({
    declarations: [
      CalendarComponent,
      AngularCalendarComponent,
      CalendarDatePipe
    ],
    imports: [
      HttpClientTestingModule,
      RouterTestingModule.withRoutes([{
        path: 'calendar',
        component: CalendarComponent
      }]),
    ],
    providers: [
      CommonUtils,
      CalendarService,
    ]
  }).compileComponents();
});

Screenshots

MicrosoftTeams-image (2)

Versions

  • @angular/core: 12.0.1
  • angular-calendar: 0.29.0
  • Browser name and version: Google Chrome - Version 97.0.4692.99 (Official Build) (64-bit)

prajwal-unext avatar Feb 15 '22 07:02 prajwal-unext

Thanks so much for opening an issue! If you'd like me to give priority to answering your issue or would just like to support this project, then please consider sponsoring me

matts-bot[bot] avatar Feb 15 '22 07:02 matts-bot[bot]

I just solved this after quite a bit of struggle.

It turns out that you need to import the CalendarCommonModule in your TestBed configuration. Mine also asked to provide DateAdapter, and CalendarDateFormatter from this package.

Hope this helps!

scottboyd-ai avatar Jul 10 '22 18:07 scottboyd-ai