MCPcopy Create free account
hub / github.com/dailydotdev/apps / renderWithHighlightLayout

Function renderWithHighlightLayout

packages/shared/src/components/Feed.spec.tsx:1792–1907  ·  view source on GitHub ↗
({
  posts,
  highlightEnabled,
  numCards = 4,
  pageSize = 25,
  adStart = 4,
  adRepeat = 8,
  minSpacing = 5,
  startIndex = 0,
  briefBannerPage,
  staticAd,
  disableAds,
  user = defaultUser,
}: HighlightLayoutRenderParams)

Source from the content-addressed store, hash-verified

1790}
1791
1792const renderWithHighlightLayout = ({
1793 posts,
1794 highlightEnabled,
1795 numCards = 4,
1796 pageSize = 25,
1797 adStart = 4,
1798 adRepeat = 8,
1799 minSpacing = 5,
1800 startIndex = 0,
1801 briefBannerPage,
1802 staticAd,
1803 disableAds,
1804 user = defaultUser,
1805}: HighlightLayoutRenderParams): RenderResult => {
1806 variables = { ...defaultVariables, first: pageSize, columns: numCards };
1807 mockGraphQL(createFeedMock(buildFeedPage(posts)));
1808 // First ad page uses active=false, subsequent pages use active=true. Mock
1809 // both up to a handful of refills so multi-ad scenarios don't run dry.
1810 nock('http://localhost:3000').get('/v1/a?active=false').reply(200, [ad]);
1811 nock('http://localhost:3000')
1812 .get('/v1/a?active=true')
1813 .times(10)
1814 .reply(200, [ad]);
1815
1816 const feedContextValue: FeedContextData = {
1817 pageSize,
1818 numCards: {
1819 eco: numCards,
1820 roomy: numCards,
1821 cozy: numCards,
1822 } as FeedContextData['numCards'],
1823 adTemplate: { adStart, adRepeat },
1824 };
1825
1826 const gb = new GrowthBook();
1827 gb.setFeatures({
1828 [featureHeroCards.id]: {
1829 defaultValue: {
1830 enabled: highlightEnabled,
1831 minSpacing,
1832 startIndex,
1833 chipLabels: {},
1834 },
1835 },
1836 ...(briefBannerPage
1837 ? {
1838 [briefFeedEntrypointPage.id]: {
1839 defaultValue: briefBannerPage,
1840 },
1841 }
1842 : {}),
1843 });
1844
1845 const settingsContext: SettingsContextData = {
1846 ...baseSettingsContext,
1847 setTheme: jest.fn(),
1848 setSpaciness: jest.fn(),
1849 toggleOpenNewTab: jest.fn(),

Callers 1

Feed.spec.tsxFile · 0.85

Calls 3

mockGraphQLFunction · 0.90
buildFeedPageFunction · 0.85
createFeedMockFunction · 0.70

Tested by

no test coverage detected