Skip to content

Commit

Permalink
update types used in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cemms1 committed Jan 16, 2025
1 parent dde0ab0 commit 226bc4e
Showing 1 changed file with 30 additions and 57 deletions.
87 changes: 30 additions & 57 deletions dotcom-rendering/src/lib/getFrontsAdPositions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
testCollectionsUk,
testCollectionsUs,
} from '../../fixtures/manual/frontCollections';
import type { DCRCollectionType } from '../types/front';
import {
type AdCandidate,
getFrontsBannerAdPositions,
Expand Down Expand Up @@ -59,7 +58,7 @@ describe('Mobile Ads', () => {

// We used https://www.theguardian.com/uk/commentisfree as a blueprint
it('Non-network front, with more than 4 collections, without thrashers', () => {
const testCollections: Pick<DCRCollectionType, 'collectionType'>[] = [
const testCollections: AdCandidate[] = [
{ collectionType: 'fixed/large/slow-XIV' },
{ collectionType: 'fixed/medium/slow-VI' },
{ collectionType: 'fixed/small/slow-IV' },
Expand All @@ -82,7 +81,7 @@ describe('Mobile Ads', () => {

// We used https://www.theguardian.com/uk as a blueprint
it('UK Network Front, with more than 4 collections, with thrashers at various places', () => {
const testCollections: Pick<DCRCollectionType, 'collectionType'>[] = [
const testCollections: AdCandidate[] = [
{ collectionType: 'dynamic/fast' },
{ collectionType: 'fixed/small/slow-IV' },
{ collectionType: 'dynamic/slow' },
Expand Down Expand Up @@ -116,7 +115,7 @@ describe('Mobile Ads', () => {

// We used https://www.theguardian.com/international as a blueprint
it('International Network Front, with more than 4 collections, with thrashers at various places', () => {
const testCollections: Pick<DCRCollectionType, 'collectionType'>[] = [
const testCollections: AdCandidate[] = [
{ collectionType: 'dynamic/fast' },
{ collectionType: 'fixed/small/slow-IV' },
{ collectionType: 'dynamic/slow' },
Expand Down Expand Up @@ -146,7 +145,7 @@ describe('Mobile Ads', () => {

// We used https://www.theguardian.com/us as a blueprint
it('US Network Front, with more than 4 collections, with thrashers at various places', () => {
const testCollections: Pick<DCRCollectionType, 'collectionType'>[] = [
const testCollections: AdCandidate[] = [
{ collectionType: 'dynamic/fast' },
{ collectionType: 'fixed/small/slow-IV' },
{ collectionType: 'fixed/small/slow-IV' },
Expand Down Expand Up @@ -177,7 +176,7 @@ describe('Mobile Ads', () => {

// We used https://www.theguardian.com/uk/lifeandstyle as a blueprint
it('Lifeandstyle front, with more than 4 collections, with thrashers at various places', () => {
const testCollections: Pick<DCRCollectionType, 'collectionType'>[] = [
const testCollections: AdCandidate[] = [
{ collectionType: 'dynamic/slow' },
{ collectionType: 'fixed/medium/slow-VI' },
{ collectionType: 'fixed/thrasher' },
Expand All @@ -203,7 +202,7 @@ describe('Mobile Ads', () => {

// We used https://www.theguardian.com/tone/recipes as a blueprint
it('Recipes front, with more than 4 collections, with thrasher at the first position', () => {
const testCollections: Pick<DCRCollectionType, 'collectionType'>[] = [
const testCollections: AdCandidate[] = [
{ collectionType: 'fixed/thrasher' },
{ collectionType: 'fixed/medium/slow-VI' },
{ collectionType: 'fixed/small/slow-V-third' },
Expand All @@ -227,78 +226,52 @@ describe('Mobile Ads', () => {

it('Europe Network Front, with beta containers and more than 4 collections, with thrashers in various places', () => {
const testCollections: AdCandidate[] = [
{ collectionType: 'flexible/general', containerLevel: 'Primary' }, // Ad position 0
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' },
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' },
{ collectionType: 'flexible/general', containerLevel: 'Primary' }, // Ad position (0)
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' }, // Ignored - is before secondary container
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' }, // Ignored - is before secondary container
{
collectionType: 'scrollable/medium',
containerLevel: 'Secondary',
},
}, // Ignored - is before secondary container
{
collectionType: 'scrollable/feature',
containerLevel: 'Secondary',
}, // Ad position 4
{ collectionType: 'static/feature/2', containerLevel: 'Primary' },
{
collectionType: 'scrollable/medium',
containerLevel: 'Secondary',
}, // Ad position 6
{ collectionType: 'flexible/special', containerLevel: 'Primary' },
{ collectionType: 'fixed/thrasher' }, // Ad position 8
{ collectionType: 'flexible/general', containerLevel: 'Primary' },
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' }, // Ad position 10
{ collectionType: 'static/feature/2', containerLevel: 'Primary' },
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' },
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' },
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' }, // Ad position 14
{ collectionType: 'static/feature/2', containerLevel: 'Primary' },
{
collectionType: 'scrollable/medium',
containerLevel: 'Secondary',
},
{
collectionType: 'scrollable/medium',
containerLevel: 'Secondary',
},
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' },
{ collectionType: 'fixed/thrasher' }, // Ad position 19
{ collectionType: 'static/feature/2', containerLevel: 'Primary' },
}, // Ad position (4)
{ collectionType: 'static/feature/2', containerLevel: 'Primary' }, // Ignored - is before secondary container
{
collectionType: 'scrollable/medium',
containerLevel: 'Secondary',
},
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' },
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' },
}, // Ad position (6)
{ collectionType: 'flexible/special', containerLevel: 'Primary' }, // Ignored - is before thrasher
{ collectionType: 'fixed/thrasher' }, // Ad position (8)
{ collectionType: 'flexible/general', containerLevel: 'Primary' }, // Ignored - is before secondary container
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' }, // Ad position (10)
{ collectionType: 'static/feature/2', containerLevel: 'Primary' }, // Ignored - is before secondary container
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' }, // Ignored - is before secondary container
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' }, // Ignored - is before secondary container
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' }, // Ad position (14)
{ collectionType: 'static/feature/2', containerLevel: 'Primary' }, // Ignored - is before secondary container
{
collectionType: 'scrollable/medium',
containerLevel: 'Secondary',
},
}, // Ignored - is before secondary container
{
collectionType: 'scrollable/medium',
containerLevel: 'Secondary',
},
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' },
{
collectionType: 'scrollable/medium',
containerLevel: 'Secondary',
}, // Ad position 27
{ collectionType: 'flexible/general', containerLevel: 'Primary' },
{
collectionType: 'scrollable/medium',
containerLevel: 'Secondary',
},
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' }, // Ad position 30
{ collectionType: 'flexible/general', containerLevel: 'Primary' },
}, // Ignored - is before secondary container
{ collectionType: 'scrollable/small', containerLevel: 'Secondary' }, // Ignored - is before thrasher
{ collectionType: 'fixed/thrasher' }, // Ad position (19)
{ collectionType: 'flexible/general', containerLevel: 'Primary' }, // Ignored - is before secondary container
{
collectionType: 'scrollable/feature',
containerLevel: 'Secondary',
},
{ collectionType: 'news/most-popular' },
}, // Ad position (21)
{ collectionType: 'news/most-popular' }, // Ignored - is most viewed container
];

const mobileAdPositions = getMobileAdPositions(testCollections);

expect(mobileAdPositions).toEqual([0, 4, 6, 8, 10, 14, 19, 27, 30, 32]);
expect(mobileAdPositions).toEqual([0, 4, 6, 8, 10, 14, 19, 21]);
});
});

Expand Down

0 comments on commit 226bc4e

Please sign in to comment.