Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test(`should provide a mock greet service`, async () => {
const component = await render(AppComponent, {
declarations: [AppComponent],
imports: [ReactiveFormsModule],
providers: [provideMockStore(), provideMock(GreetService)],
});
const service: GreetService = TestBed.get(GreetService);
component.click(component.getByText('Greet'));
expect(service.greet).toHaveBeenCalled();
});
test('renders the current value and can increment and decrement with provideMocked from jest-utils', async () => {
const component = await render(ComponentWithProviderComponent, {
componentProviders: [provideMock(CounterService)],
});
const incrementControl = component.getByText('Increment');
const decrementControl = component.getByText('Decrement');
component.click(incrementControl);
component.click(incrementControl);
component.click(decrementControl);
const counterService = TestBed.get(CounterService) as Mock;
expect(counterService.increment).toHaveBeenCalledTimes(2);
expect(counterService.decrement).toHaveBeenCalledTimes(1);
});