I am using a function in my actual service but I want to know how can i inject that function in unit test case. Below isSameDay is a function not provider. How can i inject it into test case as this function is working fine in actual service.
import { LoggerService, isSameDay } from '../../../shared';
describe('NavBaseComponent', () => {
let component: NavBaseComponent;
let fixture: ComponentFixture<NavBaseComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [NavBaseComponent],
providers: [
LoggerService
]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(NavBaseComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});
Code for isSameDay function
export function isSameDay(d1: Date, d2: Date): boolean {
return !!d1 && !!d2 &&
d1.getDate() === d2.getDate() &&
d1.getMonth() === d2.getMonth() &&
d1.getFullYear() === d2.getFullYear();
};