mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
35 lines
773 B
JavaScript
35 lines
773 B
JavaScript
const { addMatchers } = require('add-matchers');
|
|
|
|
require('jasmine-expect');
|
|
|
|
addMatchers({
|
|
toBeError(value) {
|
|
return value instanceof Error;
|
|
},
|
|
toBeErrorOfType(other, value) {
|
|
return value instanceof Error && value.name === other;
|
|
},
|
|
toBeInstanceOf(other, value) {
|
|
let otherName;
|
|
let valueName;
|
|
|
|
if (typeof value !== 'object') {
|
|
throw new TypeError(`Expected object value, got ${typeof value}`);
|
|
}
|
|
|
|
valueName = value.constructor.name;
|
|
|
|
// Class name.
|
|
if (typeof other === 'string') {
|
|
otherName = other;
|
|
// Class constructor.
|
|
} else if (typeof other === 'function') {
|
|
otherName = other.name;
|
|
} else {
|
|
otherName = other.constructor.name;
|
|
}
|
|
|
|
return valueName === otherName;
|
|
},
|
|
});
|