@@ -92,6 +92,99 @@ describe('View class', () => {
9292 assert . calledOnce ( loadStub ) ;
9393 } ) ;
9494
95+ it ( 'passes title to iframe constructor for product component' , async ( ) => {
96+ component . options . text = { button : 'ADD TO CART' } ;
97+ const iframeConstructorSpy = sinon . spy ( Iframe ) ;
98+ const originalIframe = Iframe ;
99+ Iframe = iframeConstructorSpy ;
100+
101+ await view . init ( ) ;
102+
103+ assert . calledWith ( iframeConstructorSpy , component . node , sinon . match ( {
104+ title : 'ADD TO CART'
105+ } ) ) ;
106+
107+ Iframe = originalIframe ;
108+ } ) ;
109+
110+ it ( 'passes title to iframe constructor for cart component' , async ( ) => {
111+ component . typeKey = 'cart' ;
112+ component . options . text = { title : 'Cart' } ;
113+ const iframeConstructorSpy = sinon . spy ( Iframe ) ;
114+ const originalIframe = Iframe ;
115+ Iframe = iframeConstructorSpy ;
116+
117+ await view . init ( ) ;
118+
119+ assert . calledWith ( iframeConstructorSpy , component . node , sinon . match ( {
120+ title : 'Cart'
121+ } ) ) ;
122+
123+ Iframe = originalIframe ;
124+ } ) ;
125+
126+ it ( 'passes title to iframe constructor for toggle component' , async ( ) => {
127+ component . typeKey = 'toggle' ;
128+ component . options . text = { iframeAccessibilityLabel : 'Cart toggle' } ;
129+ const iframeConstructorSpy = sinon . spy ( Iframe ) ;
130+ const originalIframe = Iframe ;
131+ Iframe = iframeConstructorSpy ;
132+
133+ await view . init ( ) ;
134+
135+ assert . calledWith ( iframeConstructorSpy , component . node , sinon . match ( {
136+ title : 'Cart toggle'
137+ } ) ) ;
138+
139+ Iframe = originalIframe ;
140+ } ) ;
141+
142+ it ( 'passes title to iframe constructor for modal component' , async ( ) => {
143+ component . typeKey = 'modal' ;
144+ component . options . text = { iframeAccessibilityLabel : 'Product modal' } ;
145+ const iframeConstructorSpy = sinon . spy ( Iframe ) ;
146+ const originalIframe = Iframe ;
147+ Iframe = iframeConstructorSpy ;
148+
149+ await view . init ( ) ;
150+
151+ assert . calledWith ( iframeConstructorSpy , component . node , sinon . match ( {
152+ title : 'Product modal'
153+ } ) ) ;
154+
155+ Iframe = originalIframe ;
156+ } ) ;
157+
158+ it ( 'passes title to iframe constructor for productSet component' , async ( ) => {
159+ component . typeKey = 'productSet' ;
160+ component . options . text = { iframeAccessibilityLabel : 'Product collection' } ;
161+ const iframeConstructorSpy = sinon . spy ( Iframe ) ;
162+ const originalIframe = Iframe ;
163+ Iframe = iframeConstructorSpy ;
164+
165+ await view . init ( ) ;
166+
167+ assert . calledWith ( iframeConstructorSpy , component . node , sinon . match ( {
168+ title : 'Product collection'
169+ } ) ) ;
170+
171+ Iframe = originalIframe ;
172+ } ) ;
173+
174+ it ( 'passes default title when text is not provided' , async ( ) => {
175+ const iframeConstructorSpy = sinon . spy ( Iframe ) ;
176+ const originalIframe = Iframe ;
177+ Iframe = iframeConstructorSpy ;
178+
179+ await view . init ( ) ;
180+
181+ assert . calledWith ( iframeConstructorSpy , component . node , sinon . match ( {
182+ title : 'Add to cart'
183+ } ) ) ;
184+
185+ Iframe = originalIframe ;
186+ } ) ;
187+
95188 it ( 'returns the response of iframe\'s load()' , async ( ) => {
96189 const response = await view . init ( ) ;
97190 assert . equal ( response , loadRes ) ;
0 commit comments