UNPKG

885 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const engine_1 = require("@dxcli/engine");
4/**
5 * tests a dxcli hook
6 *
7 * @example <caption>check that when the 'init' hook is ran it outputs "this output"</caption>
8 * testHook('init', {id: 'mycommand'}, {stdout: true}, output => {
9 * expect(output.stdout).to.contain('this output')
10 * })
11 *
12 * @param event - hook to run
13 * @param hookOpts - options to pass to hook. Config object will be passed automatically.
14 * @param opts - test options
15 */
16exports.default = (event, hookOpts = {}, opts = {}) => ({
17 async run(ctx) {
18 ctx.expectation = ctx.expectation || `runs ${event} hook`;
19 const engine = new engine_1.Engine();
20 await engine.load(opts.root || module.parent.parent.filename);
21 await engine.runHook(event, hookOpts || {});
22 }
23});
24//# sourceMappingURL=hook.js.map
\No newline at end of file