1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | return new (P || (P = Promise))(function (resolve, reject) {
|
4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
7 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8 | });
|
9 | };
|
10 | Object.defineProperty(exports, "__esModule", { value: true });
|
11 | const path = require("path");
|
12 | const execa = require("execa");
|
13 | const pkg = require('../package');
|
14 | const bin = (args = [], options = {}) => __awaiter(this, void 0, void 0, function* () {
|
15 | try {
|
16 | return yield execa('ts-node', [path.join(__dirname, './cli.ts'), ...args], options);
|
17 | }
|
18 | catch (err) {
|
19 | return err;
|
20 | }
|
21 | });
|
22 | test('prints help with non-zero exit code', () => __awaiter(this, void 0, void 0, function* () {
|
23 | const result = yield bin([], { input: '' });
|
24 | expect(result.code).not.toBe(0);
|
25 | expect(result.stdout).toContain('svg-term: either stdin or --cast are required');
|
26 | }));
|
27 | test('prints help with zero exit code for --help', () => __awaiter(this, void 0, void 0, function* () {
|
28 | const result = yield bin(['--help'], { input: '' });
|
29 | expect(result.code).toBe(0);
|
30 | expect(result.stdout).toContain('print this help');
|
31 | }));
|
32 | test('prints version with zero exit code for --version', () => __awaiter(this, void 0, void 0, function* () {
|
33 | const result = yield bin(['--version'], { input: '' });
|
34 | expect(result.code).toBe(0);
|
35 | expect(result.stdout).toBe(pkg.version);
|
36 | }));
|
37 | test('works for minimal stdin input', () => __awaiter(this, void 0, void 0, function* () {
|
38 | const result = yield bin([], { input: '[{"version": 2, "width": 1, "height": 1}, [1, "o", "foo"]]' });
|
39 | expect(result.code).toBe(0);
|
40 | }));
|