Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('renders the current value and can increment and decrement with a mocked jest-utils service', async () => {
const counter = createMock(CounterService);
let fakeCounterValue = 50;
counter.increment.mockImplementation(() => (fakeCounterValue += 10));
counter.decrement.mockImplementation(() => (fakeCounterValue -= 10));
counter.value.mockImplementation(() => fakeCounterValue);
const component = await render(ComponentWithProviderComponent, {
componentProviders: [
{
provide: CounterService,
useValue: counter,
},
],
});
const incrementControl = component.getByText('Increment');
const decrementControl = component.getByText('Decrement');