MCPcopy Create free account
hub / github.com/feiyu563/PrometheusAlert / expectedException

Function expectedException

static/plugins/pdfmake/pdfmake.js:378–429  ·  view source on GitHub ↗
(actual, expected, msg, fn)

Source from the content-addressed store, hash-verified

376}
377
378function expectedException(actual, expected, msg, fn) {
379 if (typeof expected !== 'function') {
380 if (isRegExp(expected)) return expected.test(actual); // assert.doesNotThrow does not accept objects.
381
382 if (arguments.length === 2) {
383 throw new ERR_INVALID_ARG_TYPE('expected', ['Function', 'RegExp'], expected);
384 } // Handle primitives properly.
385
386
387 if (_typeof(actual) !== 'object' || actual === null) {
388 var err = new AssertionError({
389 actual: actual,
390 expected: expected,
391 message: msg,
392 operator: 'deepStrictEqual',
393 stackStartFn: fn
394 });
395 err.operator = fn.name;
396 throw err;
397 }
398
399 var keys = Object.keys(expected); // Special handle errors to make sure the name and the message are compared
400 // as well.
401
402 if (expected instanceof Error) {
403 keys.push('name', 'message');
404 } else if (keys.length === 0) {
405 throw new ERR_INVALID_ARG_VALUE('error', expected, 'may not be an empty object');
406 }
407
408 if (isDeepEqual === undefined) lazyLoadComparison();
409 keys.forEach(function (key) {
410 if (typeof actual[key] === 'string' && isRegExp(expected[key]) && expected[key].test(actual[key])) {
411 return;
412 }
413
414 compareExceptionKey(actual, expected, key, msg, keys, fn);
415 });
416 return true;
417 } // Guard instanceof against arrow functions as they don't have a prototype.
418
419
420 if (expected.prototype !== undefined && actual instanceof expected) {
421 return true;
422 }
423
424 if (Error.isPrototypeOf(expected)) {
425 return false;
426 }
427
428 return expected.call({}, actual) === true;
429}
430
431function getActual(fn) {
432 if (typeof fn !== 'function') {

Callers 2

expectsErrorFunction · 0.70
expectsNoErrorFunction · 0.70

Calls 4

isRegExpFunction · 0.70
_typeofFunction · 0.70
lazyLoadComparisonFunction · 0.70
compareExceptionKeyFunction · 0.70

Tested by

no test coverage detected