1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const _ = require("lodash");
|
4 | const chai_1 = require("./chai");
|
5 | exports.default = (arg, opts = {}) => ({
|
6 | run() {
|
7 | if (opts.raiseIfNotThrown !== false) {
|
8 | throw new Error('expected error to be thrown');
|
9 | }
|
10 | },
|
11 | catch(ctx) {
|
12 | const err = ctx.error;
|
13 | if (_.isRegExp(arg)) {
|
14 | (0, chai_1.expect)(err.message).to.match(arg);
|
15 | }
|
16 | else if (_.isString(arg)) {
|
17 | (0, chai_1.expect)(err.message).to.equal(arg);
|
18 | }
|
19 | else if (arg) {
|
20 | arg(err);
|
21 | }
|
22 | else {
|
23 | throw new Error('no arg provided to catch');
|
24 | }
|
25 | },
|
26 | });
|