Class IsPageVisibleHarness

Use to control isPageVisible$() in tests. Create only one per test, before anything calls 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);

It also stubs document.visibilityState to match.

const isPageVisibleHarness = new IsPageVisibleHarness();
expect(document.visibilityState).toBe('visible');

isPageVisibleHarness.setVisible(false);
expect(document.visibilityState).toBe('hidden');

Constructors

Methods

Constructors

Methods