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

Function installWrappers

build-system/tasks/e2e/expect.js:130–159  ·  view source on GitHub ↗

* @param {Chai.ChaiStatic} chai * @param {Chai.ChaiUtils} utils

(chai, utils)

Source from the content-addressed store, hash-verified

128 * @param {Chai.ChaiUtils} utils
129 */
130function installWrappers(chai, utils) {
131 const {CHAINABLE_METHOD, METHOD, PROPERTY} = ChaiType;
132 const {Assertion} = chai;
133
134 for (const {name, type, unsupported} of chaiMethodsAndProperties) {
135 /** @type {function(Chai.AssertionStatic): void} */
136 const overwrite = unsupported
137 ? overwriteUnsupported
138 : overwriteAlwaysUseSuper(utils);
139
140 switch (type) {
141 case METHOD:
142 Assertion.overwriteMethod(name, overwrite);
143 break;
144 case PROPERTY:
145 // TODO(#28387) cleanup this type.
146 Assertion.overwriteProperty(name, /** @type {*} */ (overwrite));
147 break;
148 case CHAINABLE_METHOD:
149 Assertion.overwriteChainableMethod(
150 name,
151 overwrite,
152 /** @type {() => any} */ (inheritChainingBehavior)
153 );
154 break;
155 default:
156 throw new Error('Unknown ChaiType');
157 }
158 }
159}
160
161/**
162 * @param {Chai.ChaiUtils} utils

Callers

nothing calls this directly

Calls 1

overwriteAlwaysUseSuperFunction · 0.85

Tested by

no test coverage detected