MCPcopy
hub / github.com/ampproject/amphtml / extensionRegistrationTest

Function extensionRegistrationTest

test/unit/test-runtime.js:138–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136 });
137
138 function extensionRegistrationTest() {
139 let progress = '';
140 const queueExtensions = win.AMP;
141 win.AMP.push(
142 regularExtension((amp) => {
143 expect(amp).to.equal(win.AMP);
144 progress += '1';
145 })
146 );
147 win.AMP.push(
148 regularExtension((amp) => {
149 expect(amp).to.equal(win.AMP);
150 progress += '2';
151 })
152 );
153 win.AMP.push(
154 regularExtension((amp) => {
155 expect(amp).to.equal(win.AMP);
156 progress += '3';
157 })
158 );
159 expect(queueExtensions).to.have.length(3);
160 const promise = adopt(win);
161 runChunks(win.document);
162 return promise
163 .then(() => {
164 expect(queueExtensions).to.have.length(0);
165 expect(progress).to.equal('123');
166 win.AMP.push(
167 regularExtension((amp) => {
168 expect(amp).to.equal(win.AMP);
169 progress += '4';
170 })
171 );
172 runChunks(win.document);
173 return promise;
174 })
175 .then(() => {
176 expect(progress).to.equal('1234');
177 win.AMP.push(
178 regularExtension((amp) => {
179 expect(amp).to.equal(win.AMP);
180 progress += '5';
181 })
182 );
183 runChunks(win.document);
184 return promise;
185 })
186 .then(() => {
187 expect(progress).to.equal('12345');
188 expect(queueExtensions).to.have.length(0);
189 });
190 }
191
192 it(
193 'should execute scheduled extensions & execute new extensions',

Callers 1

test-runtime.jsFile · 0.85

Calls 7

adoptFunction · 0.90
regularExtensionFunction · 0.85
expectFunction · 0.85
runChunksFunction · 0.85
lengthMethod · 0.80
pushMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected