Use to control isPageVisible$() in tests. Create only one per test, before anything calls isPageVisible$().
isPageVisible$()
const isPageVisibleHarness = new IsPageVisibleHarness();isPageVisibleHarness.setVisible(false);const next = jasmine.createSpy();isPageVisible$().subscribe(next);expect(next).toHaveBeenCalledWith(false);isPageVisibleHarness.setVisible(true);expect(next).toHaveBeenCalledWith(true); Copy
const isPageVisibleHarness = new IsPageVisibleHarness();isPageVisibleHarness.setVisible(false);const next = jasmine.createSpy();isPageVisible$().subscribe(next);expect(next).toHaveBeenCalledWith(false);isPageVisibleHarness.setVisible(true);expect(next).toHaveBeenCalledWith(true);
It also stubs document.visibilityState to match.
document.visibilityState
const isPageVisibleHarness = new IsPageVisibleHarness();expect(document.visibilityState).toBe('visible');isPageVisibleHarness.setVisible(false);expect(document.visibilityState).toBe('hidden'); Copy
const isPageVisibleHarness = new IsPageVisibleHarness();expect(document.visibilityState).toBe('visible');isPageVisibleHarness.setVisible(false);expect(document.visibilityState).toBe('hidden');
Sets the page's visibility state, and triggers any subscriptions to isPageVisible$(). Automatically triggers change detection if running with an AngularContext.
AngularContext
Use to control isPageVisible$() in tests. Create only one per test, before anything calls
isPageVisible$()
.It also stubs
document.visibilityState
to match.