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

Function mockServiceForDoc

testing/helpers/service.js:36–50  ·  view source on GitHub ↗
(sandbox, ampdoc, serviceId, methods)

Source from the content-addressed store, hash-verified

34}
35
36export function mockServiceForDoc(sandbox, ampdoc, serviceId, methods) {
37 resetServiceForTesting(ampdoc.win, serviceId);
38 const impl = {};
39 methods.forEach((method) => {
40 impl[method] = () => {};
41 });
42 registerServiceBuilderForDoc(ampdoc, serviceId, function () {
43 return impl;
44 });
45 const mock = {};
46 methods.forEach((method) => {
47 mock[method] = sandbox.stub(impl, method);
48 });
49 return mock;
50}
51
52export function mockWindowInterface(sandbox) {
53 const methods = Object.getOwnPropertyNames(WindowInterface).filter(

Calls 3

resetServiceForTestingFunction · 0.90
forEachMethod · 0.45

Tested by

no test coverage detected