Skip to content

Commit 8308dac

Browse files
Merge pull request #13679 from bbc/WS-2012-live-page-refresh-spike
[WS-2012] Initial Implementation of Live Page Refresh button (Frontend only)
2 parents aaf75c2 + de5ffcc commit 8308dac

File tree

18 files changed

+6974
-88
lines changed

18 files changed

+6974
-88
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
export default class MockIntersectionObserver {
2+
observers;
3+
4+
constructor() {
5+
this.observers = new Map();
6+
}
7+
8+
getMockIntersectionObserver = () => {
9+
const mockIntersectionObserver = cb => {
10+
const item = {
11+
callback: cb,
12+
elements: new Set(),
13+
};
14+
15+
const instance = {
16+
observe: jest.fn(element => {
17+
item.elements.add(element);
18+
}),
19+
disconnect: jest.fn(() => {
20+
item.elements.clear();
21+
}),
22+
};
23+
24+
this.observers.set(instance, item);
25+
26+
return instance;
27+
};
28+
29+
return mockIntersectionObserver;
30+
};
31+
32+
triggerAllObservers = () => {
33+
this.observers.forEach(item => {
34+
item.callback([
35+
{ isIntersecting: true, boundingClientRect: { bottom: 1 } },
36+
]);
37+
});
38+
};
39+
40+
clearObservers = () => {
41+
this.observers.clear();
42+
};
43+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ComponentProps } from '#nextjs/pages/[service]/live/[id]/LivePageLayout';
2+
3+
// This is a placeholder function, this will be replaced by a proper fetch statement to the BFF in due time.
4+
export default () => {
5+
return null as unknown as ComponentProps['pageData'];
6+
};

0 commit comments

Comments
 (0)