mattlewis92 / angular-calendar

A flexible calendar component for angular 15.0+ that can display events on a month, week or day view.
https://mattlewis92.github.io/angular-calendar/
MIT License
2.72k stars 863 forks source link

unit testing: calendar-date.pipe error #1558

Open prajwal-unext opened 2 years ago

prajwal-unext commented 2 years ago

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

matts-bot[bot] commented 2 years ago

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

scottboyd-ai commented 2 years ago

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!