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

Function noopMethods

ads/google/a4a/test/test-utils.js:58–79  ·  view source on GitHub ↗
(
  impl,
  ampdoc,
  sandbox,
  pageLayoutBox = {
    top: 11.1,
    left: 12.1,
    width: 0,
    height: 0,
  }
)

Source from the content-addressed store, hash-verified

56// machinery that AMP expects it to have, so just no-op the irrelevant
57// functions.
58function noopMethods(
59 impl,
60 ampdoc,
61 sandbox,
62 pageLayoutBox = {
63 top: 11.1,
64 left: 12.1,
65 width: 0,
66 height: 0,
67 }
68) {
69 const noop = () => {};
70 impl.element.buildInternal = noop;
71 impl.element.getPlaceholder = noop;
72 impl.element.createPlaceholder = noop;
73 sandbox.stub(impl, 'getAmpDoc').returns(ampdoc);
74 sandbox.stub(impl.element, 'offsetParent').value(null);
75 sandbox.stub(impl.element, 'offsetTop').value(pageLayoutBox.top);
76 sandbox.stub(impl.element, 'offsetLeft').value(pageLayoutBox.left);
77 sandbox.stub(impl.element, 'offsetWidth').value(pageLayoutBox.width);
78 sandbox.stub(impl.element, 'offsetHeight').value(pageLayoutBox.height);
79}
80
81describes.sandboxed('Google A4A utils', {}, (env) => {
82 //TODO: Add tests for other utils functions.

Callers 1

test-utils.jsFile · 0.85

Calls 1

valueMethod · 0.80

Tested by

no test coverage detected