2018-01-27 06:59:38 +08:00
|
|
|
/* globals expect */
|
|
|
|
expect.extend({
|
|
|
|
toBeTypeOf(received, expected) {
|
|
|
|
const objType = typeof received;
|
|
|
|
const pass = objType === expected;
|
|
|
|
|
|
|
|
const message = pass
|
|
|
|
? () =>
|
|
|
|
this.utils.matcherHint(".not.toBeTypeOf") +
|
|
|
|
"\n\n" +
|
|
|
|
"Expected value to not be (using typeof):\n" +
|
|
|
|
` ${this.utils.printExpected(expected)}\n` +
|
|
|
|
"Received:\n" +
|
|
|
|
` ${this.utils.printReceived(objType)}`
|
2018-01-31 04:03:23 +08:00
|
|
|
: () =>
|
|
|
|
this.utils.matcherHint(".toBeTypeOf") +
|
|
|
|
"\n\n" +
|
|
|
|
"Expected value to be (using typeof):\n" +
|
|
|
|
` ${this.utils.printExpected(expected)}\n` +
|
|
|
|
"Received:\n" +
|
|
|
|
` ${this.utils.printReceived(objType)}`;
|
2018-01-27 06:59:38 +08:00
|
|
|
|
|
|
|
return { message, pass };
|
|
|
|
}
|
|
|
|
});
|