-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use components rather than functions for fronts ads (#13134)
- Loading branch information
Showing
5 changed files
with
271 additions
and
252 deletions.
There are no files selected for viewing
92 changes: 0 additions & 92 deletions
92
dotcom-rendering/src/components/DecideFrontsAdSlots.test.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { render } from '@testing-library/react'; | ||
import { FrontsBannerAdSlot, MerchHighOrMobileAdSlot } from './FrontsAdSlots'; | ||
|
||
describe('MerchHighOrMobileAdSlot', () => { | ||
it("should return null if we shouldn't render ads", () => { | ||
const { container } = render( | ||
<MerchHighOrMobileAdSlot | ||
renderAds={false} | ||
index={4} | ||
collectionCount={10} | ||
isPaidContent={false} | ||
mobileAdPositions={[]} | ||
hasPageSkin={false} | ||
/>, | ||
); | ||
|
||
expect(container.innerHTML).toBe(''); | ||
}); | ||
}); | ||
|
||
describe('FrontsBannerAdSlot', () => { | ||
it("should return null if we shouldn't render ads", () => { | ||
const { container } = render( | ||
<FrontsBannerAdSlot | ||
renderAds={false} | ||
hasPageSkin={false} | ||
index={2} | ||
desktopAdPositions={[2, 5]} | ||
/>, | ||
); | ||
|
||
expect(container.innerHTML).toBe(''); | ||
}); | ||
|
||
it("should return null if there's a pageskin", () => { | ||
const { container } = render( | ||
<FrontsBannerAdSlot | ||
renderAds={true} | ||
hasPageSkin={true} | ||
index={2} | ||
desktopAdPositions={[2, 5]} | ||
/>, | ||
); | ||
|
||
expect(container.innerHTML).toBe(''); | ||
}); | ||
|
||
test.each([ | ||
[[2, 5], 3], | ||
[[2, 5], 0], | ||
[[], 1], | ||
])( | ||
'should return null if desktopAdPositions %p does NOT contain index %i', | ||
(adPositions, i) => { | ||
const { container } = render( | ||
<FrontsBannerAdSlot | ||
renderAds={true} | ||
hasPageSkin={false} | ||
index={i} | ||
desktopAdPositions={adPositions} | ||
/>, | ||
); | ||
|
||
expect(container.innerHTML).toBe(''); | ||
}, | ||
); | ||
|
||
test.each([ | ||
[[2, 5], 2], | ||
[[2, 5], 5], | ||
[[1], 1], | ||
])( | ||
'should NOT return null if desktopAdPositions %p contains index %i', | ||
(adPositions, i) => { | ||
const { container } = render( | ||
<FrontsBannerAdSlot | ||
renderAds={true} | ||
hasPageSkin={false} | ||
index={i} | ||
desktopAdPositions={adPositions} | ||
/>, | ||
); | ||
|
||
expect(container.innerHTML).not.toBe(''); | ||
expect(container.innerHTML).toMatch('ad-slot-container'); | ||
}, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.