(sandbox, ampdoc, serviceId, methods)
| 34 | } |
| 35 | |
| 36 | export 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 | |
| 52 | export function mockWindowInterface(sandbox) { |
| 53 | const methods = Object.getOwnPropertyNames(WindowInterface).filter( |
no test coverage detected