@@ -23,6 +23,8 @@ import {Services} from '#service';
2323
2424import { createIframeWithMessageStub } from '#testing/iframe' ;
2525
26+ import * as consent from '../../../../src/consent' ;
27+ import * as iframe from '../../../../src/iframe-attributes' ;
2628import { XORIGIN_MODE } from '../../../amp-a4a/0.1/amp-a4a' ;
2729import { AmpAdNetworkSmartadserverImpl } from '../amp-ad-network-smartadserver-impl' ;
2830
@@ -173,6 +175,51 @@ describes.realWin('amp-ad-network-smartadserver-impl', realWinConfig, (env) => {
173175 } ) ;
174176 } ) ;
175177
178+ describe ( 'renderViaIframeGet_' , ( ) => {
179+ let getContextMetadataStub ;
180+ beforeEach ( ( ) => {
181+ getContextMetadataStub = env . sandbox
182+ . stub ( iframe , 'getContextMetadata' )
183+ . returns ( {
184+ _context : { } ,
185+ } ) ;
186+ env . sandbox
187+ . stub ( consent , 'getConsentDataToForward' )
188+ . resolves ( { consentString : 'constent' , gdprApplies : true } ) ;
189+ element = createElementWithAttributes ( doc , 'amp-ad' , {
190+ width : '300' ,
191+ height : '250' ,
192+ type : 'smartadserver' ,
193+ } ) ;
194+ element . getIntersectionChangeEntry = ( ) => ( {
195+ rootBounds : { } ,
196+ intersectionRect : { } ,
197+ boundingClientRect : { } ,
198+ } ) ;
199+ impl = new AmpAdNetworkSmartadserverImpl ( element ) ;
200+ env . sandbox . stub ( impl , 'iframeRenderHelper_' ) ;
201+ } ) ;
202+ afterEach ( ( ) => {
203+ env . sandbox . restore ( ) ;
204+ } ) ;
205+ it ( 'should call maybeTriggerAnalyticsEvent_' , async ( ) => {
206+ const spy = env . sandbox . spy ( impl , 'maybeTriggerAnalyticsEvent_' ) ;
207+ expect ( spy . called ) . to . be . false ;
208+ impl . renderViaIframeGet_ ( 'fakeURL' ) . then ( ( ) => {
209+ expect ( spy . called ) . to . be . true ;
210+ } ) ;
211+ } ) ;
212+ it ( 'should call getContextMetadata with a consent data' , async ( ) => {
213+ expect ( getContextMetadataStub . called ) . to . be . false ;
214+ impl . renderViaIframeGet_ ( 'fakeURL' ) . then ( ( ) => {
215+ expect ( getContextMetadataStub . called ) . to . be . true ;
216+ expect ( getContextMetadataStub . getCall ( 0 ) . args [ 3 ] ) . to . be . deep . equal ( {
217+ 'consentSharedData' : { consentString : 'constent' , gdprApplies : true } ,
218+ } ) ;
219+ } ) ;
220+ } ) ;
221+ } ) ;
222+
176223 describe ( 'getAdUrl' , ( ) => {
177224 it ( 'should return proper url with vendor(default) data' , async ( ) => {
178225 element = createElementWithAttributes ( doc , 'amp-ad' , {
0 commit comments