9
9
type AdCandidateMobile ,
10
10
getFrontsBannerAdPositions ,
11
11
getMobileAdPositions ,
12
+ removeConsecutiveAdSlotsReducer ,
12
13
} from './getFrontsAdPositions' ;
13
14
14
15
const defaultTestCollections : AdCandidateMobile [ ] = [ ...Array < number > ( 12 ) ] . map (
@@ -60,14 +61,14 @@ describe('Mobile Ads', () => {
60
61
{ collectionType : 'fixed/medium/slow-VI' } ,
61
62
{ collectionType : 'fixed/small/slow-IV' } , // Ad position (8)
62
63
{ collectionType : 'fixed/small/slow-III' } ,
63
- { collectionType : 'fixed/medium/fast-XII' } , // Ad position (10)
64
+ { collectionType : 'fixed/medium/fast-XII' } , // Ignored - is before merch high position
64
65
{ collectionType : 'fixed/small/fast-VIII' } , // Ignored - is merch high position
65
66
{ collectionType : 'news/most-popular' } , // Ignored - is most viewed container
66
67
] ;
67
68
68
69
const mobileAdPositions = getMobileAdPositions ( testCollections ) ;
69
70
70
- expect ( mobileAdPositions ) . toEqual ( [ 0 , 2 , 4 , 6 , 8 , 10 ] ) ;
71
+ expect ( mobileAdPositions ) . toEqual ( [ 0 , 2 , 4 , 6 , 8 ] ) ;
71
72
} ) ;
72
73
73
74
// We used https://www.theguardian.com/uk as a blueprint
@@ -94,14 +95,14 @@ describe('Mobile Ads', () => {
94
95
{ collectionType : 'fixed/small/slow-IV' } ,
95
96
{ collectionType : 'fixed/small/slow-IV' } , // Ad position (19)
96
97
{ collectionType : 'dynamic/slow-mpu' } ,
97
- { collectionType : 'fixed/small/slow-IV' } , // Ad position (21)
98
+ { collectionType : 'fixed/small/slow-IV' } , // Ignored - is before merch high position
98
99
{ collectionType : 'fixed/medium/slow-VI' } , // Ignored - is merch high position
99
100
{ collectionType : 'news/most-popular' } , // Ignored - is most viewed container
100
101
] ;
101
102
102
103
const mobileAdPositions = getMobileAdPositions ( testCollections ) ;
103
104
104
- expect ( mobileAdPositions ) . toEqual ( [ 0 , 2 , 4 , 8 , 11 , 14 , 17 , 19 , 21 ] ) ;
105
+ expect ( mobileAdPositions ) . toEqual ( [ 0 , 2 , 4 , 8 , 11 , 14 , 17 , 19 ] ) ;
105
106
} ) ;
106
107
107
108
// We used https://www.theguardian.com/international as a blueprint
@@ -205,14 +206,14 @@ describe('Mobile Ads', () => {
205
206
{ collectionType : 'fixed/small/slow-III' } ,
206
207
{ collectionType : 'fixed/small/slow-IV' } , // Ad position (9)
207
208
{ collectionType : 'fixed/small/slow-V-half' } ,
208
- { collectionType : 'fixed/small/slow-V-third' } , // Ad position (11)
209
+ { collectionType : 'fixed/small/slow-V-third' } , // Ignored - is before merch high position
209
210
{ collectionType : 'fixed/small/fast-VIII' } , // Ignored - is merch high position
210
211
{ collectionType : 'news/most-popular' } , // Ignored - is most viewed container
211
212
] ;
212
213
213
214
const mobileAdPositions = getMobileAdPositions ( testCollections ) ;
214
215
215
- expect ( mobileAdPositions ) . toEqual ( [ 1 , 3 , 5 , 7 , 9 , 11 ] ) ;
216
+ expect ( mobileAdPositions ) . toEqual ( [ 1 , 3 , 5 , 7 , 9 ] ) ;
216
217
} ) ;
217
218
218
219
it ( 'Europe Network Front, with beta containers and more than 4 collections, with thrashers in various places' , ( ) => {
@@ -235,12 +236,11 @@ describe('Mobile Ads', () => {
235
236
} , // Ad position (6)
236
237
{ collectionType : 'flexible/special' , containerLevel : 'Primary' } , // Ignored - is before thrasher
237
238
{ collectionType : 'fixed/thrasher' } , // Ad position (8)
238
- { collectionType : 'flexible/general' , containerLevel : 'Primary' } , // Ignored - is before secondary container
239
- { collectionType : 'scrollable/small' , containerLevel : 'Secondary' } , // Ad position (10)
239
+ { collectionType : 'flexible/general' , containerLevel : 'Primary' } , // Ignored is consecutive ad after position 8
240
240
{ collectionType : 'static/feature/2' , containerLevel : 'Primary' } , // Ignored - is before secondary container
241
241
{ collectionType : 'scrollable/small' , containerLevel : 'Secondary' } , // Ignored - is before secondary container
242
242
{ collectionType : 'scrollable/small' , containerLevel : 'Secondary' } , // Ignored - is before secondary container
243
- { collectionType : 'scrollable/small' , containerLevel : 'Secondary' } , // Ad position (14 )
243
+ { collectionType : 'scrollable/small' , containerLevel : 'Secondary' } , // Ad position (13 )
244
244
{ collectionType : 'static/feature/2' , containerLevel : 'Primary' } , // Ignored - is before secondary container
245
245
{
246
246
collectionType : 'scrollable/medium' ,
@@ -251,7 +251,7 @@ describe('Mobile Ads', () => {
251
251
containerLevel : 'Secondary' ,
252
252
} , // Ignored - is before secondary container
253
253
{ collectionType : 'scrollable/small' , containerLevel : 'Secondary' } , // Ignored - is before thrasher
254
- { collectionType : 'fixed/thrasher' } , // Ad position (19 )
254
+ { collectionType : 'fixed/thrasher' } , // Ad position (18 )
255
255
{ collectionType : 'flexible/general' , containerLevel : 'Primary' } , // Ignored - is before secondary container
256
256
{
257
257
collectionType : 'scrollable/feature' ,
@@ -262,7 +262,7 @@ describe('Mobile Ads', () => {
262
262
263
263
const mobileAdPositions = getMobileAdPositions ( testCollections ) ;
264
264
265
- expect ( mobileAdPositions ) . toEqual ( [ 0 , 4 , 6 , 8 , 10 , 14 , 19 ] ) ;
265
+ expect ( mobileAdPositions ) . toEqual ( [ 0 , 4 , 6 , 8 , 13 , 18 ] ) ;
266
266
} ) ;
267
267
} ) ;
268
268
@@ -319,3 +319,23 @@ describe('Standard fronts fronts-banner ad slots', () => {
319
319
expect ( adPositions . length ) . toEqual ( 8 ) ;
320
320
} ) ;
321
321
} ) ;
322
+
323
+ describe ( 'removeConsecutiveAdSlotsReducer' , ( ) => {
324
+ it ( 'removes consecutive slots from array of all consecutive numbers' , ( ) => {
325
+ const arr = [ 0 , 1 , 2 , 3 , 4 , 5 ] ;
326
+ const result = arr . reduce ( removeConsecutiveAdSlotsReducer , [ ] ) ;
327
+ expect ( result ) . toEqual ( [ 0 , 2 , 4 ] ) ;
328
+ } ) ;
329
+
330
+ it ( 'removes consecutive slots from array of some consecutive numbers' , ( ) => {
331
+ const arr = [ 0 , 3 , 7 , 11 , 12 , 13 , 19 , 20 ] ;
332
+ const result = arr . reduce ( removeConsecutiveAdSlotsReducer , [ ] ) ;
333
+ expect ( result ) . toEqual ( [ 0 , 3 , 7 , 11 , 13 , 19 ] ) ;
334
+ } ) ;
335
+
336
+ it ( 'handles empty array' , ( ) => {
337
+ const arr : number [ ] = [ ] ;
338
+ const result = arr . reduce ( removeConsecutiveAdSlotsReducer , [ ] ) ;
339
+ expect ( result ) . toEqual ( [ ] ) ;
340
+ } ) ;
341
+ } ) ;
0 commit comments