MCPcopy Create free account
hub / github.com/ampproject/amphtml / verifyClientIdApiInUse

Function verifyClientIdApiInUse

test/unit/test-viewer-cid-api.js:42–63  ·  view source on GitHub ↗
(used)

Source from the content-addressed store, hash-verified

40
41 describe('getScopedCid', () => {
42 function verifyClientIdApiInUse(used) {
43 viewerMock.sendMessageAwaitResponse.returns(
44 Promise.resolve('client-id-from-viewer')
45 );
46 return api
47 .getScopedCid(used ? 'api-key' : undefined, 'AMP_ECID_GOOGLE')
48 .then((cid) => {
49 expect(cid).to.equal('client-id-from-viewer');
50 const payload = {
51 'scope': 'AMP_ECID_GOOGLE',
52 'clientIdApi': used,
53 'canonicalOrigin': 'http://localhost:9876',
54 };
55 if (used) {
56 payload['apiKey'] = 'api-key';
57 }
58 expect(viewerMock.sendMessageAwaitResponse).to.be.calledWith(
59 'cid',
60 payload
61 );
62 });
63 }
64
65 it('should use client ID API from api if everything great', () => {
66 return verifyClientIdApiInUse(true);

Callers 1

Calls 4

expectFunction · 0.85
resolveMethod · 0.80
thenMethod · 0.45
getScopedCidMethod · 0.45

Tested by

no test coverage detected