* Returns `true` if the class's source contains the given substring. * * @param {typeof BaseElement} implClass * @param {string} substring * @return {boolean}
(implClass, substring)
| 141 | * @return {boolean} |
| 142 | */ |
| 143 | function sourceIncludes(implClass, substring) { |
| 144 | const code = []; |
| 145 | code.push(implClass.toString()); |
| 146 | const classProps = Object.getOwnPropertyDescriptors(implClass); |
| 147 | for (const k in classProps) { |
| 148 | const desc = classProps[k]; |
| 149 | if (typeof desc.value == 'function') { |
| 150 | code.push(desc.value.toString()); |
| 151 | } |
| 152 | } |
| 153 | const protoProps = Object.getOwnPropertyDescriptors(implClass.prototype); |
| 154 | for (const k in protoProps) { |
| 155 | const desc = protoProps[k]; |
| 156 | if (typeof desc.value == 'function') { |
| 157 | code.push(desc.value.toString()); |
| 158 | } |
| 159 | } |
| 160 | return code.filter((code) => code.includes(substring)).length > 0; |
| 161 | } |
no test coverage detected