I have a service set up like this:
calendar-domain.service.ts
@Injectable()
export class CalendarDomainService {
private _calendarWeek = new BehaviorSubject<CalendarWeekTo | null>(null);
get calendarWeek$(): Observable<CalendarWeekTo | null> {
return this._calendarWeek.asObservable();
}
setCalendarWeek(calendarWeek: CalendarWeekTo): void {
this._calendarWeek.next(calendarWeek);
}
}
And I have a unit test for it as well:
calendar-domain.service.spec.ts
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { CalendarDomainService } from './calendar-domain.service';
describe('CalendarDomainService', () => {
let service: CalendarDomainService;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [CalendarDomainService],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]
});
service = TestBed.inject(CalendarDomainService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
However, I have not yet tested the two functions in the service. I'm unsure how to approach testing them. Any guidance on how to get started would be greatly appreciated. Thanks!