@@ -96,7 +96,11 @@ describe('Enhancing ad placeholders', () => {
9696 const expectedPlaceholders = expectedPositions . length ;
9797 const input : FEElement [ ] = elements ;
9898
99- const output = enhanceAdPlaceholders ( exampleFormat , 'Apps' ) ( input ) ;
99+ const output = enhanceAdPlaceholders (
100+ exampleFormat ,
101+ 'Apps' ,
102+ false ,
103+ ) ( input ) ;
100104 const placeholderIndices = output . flatMap ( ( el , idx ) =>
101105 elementIsAdPlaceholder ( el ) ? [ idx ] : [ ] ,
102106 ) ;
@@ -115,7 +119,7 @@ describe('Enhancing ad placeholders', () => {
115119 } ,
116120 ) ;
117121
118- describe ( 'should not insert an ad placeholder before an inline image element, but can insert it after the image' , ( ) => {
122+ it ( 'should not insert an ad placeholder before an inline image element, but can insert it after the image' , ( ) => {
119123 const threeParagraphs = getTestParagraphElements ( 3 ) ;
120124
121125 const elements = [
@@ -126,7 +130,11 @@ describe('Enhancing ad placeholders', () => {
126130
127131 const input : FEElement [ ] = elements ;
128132
129- const output = enhanceAdPlaceholders ( exampleFormat , 'Apps' ) ( input ) ;
133+ const output = enhanceAdPlaceholders (
134+ exampleFormat ,
135+ 'Apps' ,
136+ false ,
137+ ) ( input ) ;
130138 const outputPlaceholders = output . filter ( elementIsAdPlaceholder ) ;
131139
132140 expect ( outputPlaceholders . length ) . toEqual ( 1 ) ;
@@ -139,7 +147,7 @@ describe('Enhancing ad placeholders', () => {
139147 expect ( placeholderIndices ) . toEqual ( [ 4 ] ) ;
140148 } ) ;
141149
142- describe ( 'should not insert an ad placeholder after a thumbnail image element' , ( ) => {
150+ it ( 'should not insert an ad placeholder after a thumbnail image element' , ( ) => {
143151 const threeParagraphs = getTestParagraphElements ( 3 ) ;
144152
145153 const elements = [
@@ -150,7 +158,11 @@ describe('Enhancing ad placeholders', () => {
150158
151159 const input : FEElement [ ] = elements ;
152160
153- const output = enhanceAdPlaceholders ( exampleFormat , 'Apps' ) ( input ) ;
161+ const output = enhanceAdPlaceholders (
162+ exampleFormat ,
163+ 'Apps' ,
164+ false ,
165+ ) ( input ) ;
154166 const outputPlaceholders = output . filter ( elementIsAdPlaceholder ) ;
155167
156168 expect ( outputPlaceholders . length ) . toEqual ( 1 ) ;
@@ -163,7 +175,7 @@ describe('Enhancing ad placeholders', () => {
163175 expect ( placeholderIndices ) . toEqual ( [ 5 ] ) ;
164176 } ) ;
165177
166- describe ( 'should not insert an ad placeholder after an element which is not an image or text' , ( ) => {
178+ it ( 'should not insert an ad placeholder after an element which is not an image or text' , ( ) => {
167179 const threeParagraphs = getTestParagraphElements ( 3 ) ;
168180
169181 const elements = [
@@ -174,7 +186,11 @@ describe('Enhancing ad placeholders', () => {
174186
175187 const input : FEElement [ ] = elements ;
176188
177- const output = enhanceAdPlaceholders ( exampleFormat , 'Apps' ) ( input ) ;
189+ const output = enhanceAdPlaceholders (
190+ exampleFormat ,
191+ 'Apps' ,
192+ false ,
193+ ) ( input ) ;
178194 const outputPlaceholders = output . filter ( elementIsAdPlaceholder ) ;
179195
180196 expect ( outputPlaceholders . length ) . toEqual ( 1 ) ;
@@ -186,4 +202,17 @@ describe('Enhancing ad placeholders', () => {
186202 // Expect one placeholder to be present after the fifth element only
187203 expect ( placeholderIndices ) . toEqual ( [ 5 ] ) ;
188204 } ) ;
205+
206+ it ( 'should not insert ad placeholders if shouldHideAds is true' , ( ) => {
207+ const input : FEElement [ ] = getTestParagraphElements ( 6 ) ;
208+
209+ const output = enhanceAdPlaceholders (
210+ exampleFormat ,
211+ 'Apps' ,
212+ true ,
213+ ) ( input ) ;
214+ const outputPlaceholders = output . filter ( elementIsAdPlaceholder ) ;
215+
216+ expect ( outputPlaceholders . length ) . toEqual ( 0 ) ;
217+ } ) ;
189218} ) ;
0 commit comments