Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const error = new Error('oops!');
const MyComponent = createComponent(
() => concat(of(7), throwError(error)),
template
);
/* eslint-disable no-console */
const temp = console.error;
console.error = jest.fn();
render(root, MyComponent);
expect(console.error).toHaveBeenCalledWith('Error: ', error);
console.error = temp;
/* eslint-enable no-console */
});
it(
'should not emit a warning message after if component emits state before 500ms if not state updates',
fakeSchedulers(advance => {
jest.useFakeTimers();
const root = document.createElement('div');
const MyComponent = createComponent(({ props }) => props, template);
render(root, MyComponent, { value: 'foo' });
/* eslint-disable no-console */
const temp = console.warn;
console.warn = jest.fn();
advance(500);
expect(console.warn).not.toHaveBeenCalledWith(
'Warning: Your Component did not emit any state updates for at least 500ms.'
);
console.warn = temp;
/* eslint-enable no-console */
})
);
it('should unmount replaced components', () => {
it(
"should support a timer",
fakeSchedulers(advance => {
let received: number | undefined;
timer(100).subscribe(value => (received = value));
advance(50);
expect(received).not.toBeDefined();
advance(50);
expect(received).toBe(0);
})
);
it(
"should support delay",
fakeSchedulers(advance => {
let received: number | undefined;
of(1)
.pipe(delay(100))
.subscribe(value => (received = value));
advance(50);
expect(received).not.toBeDefined();
advance(50);
expect(received).toBe(1);
})
);
});