2022-05-17 12:18:06 +00:00
|
|
|
import { describe, expect, it } from '@jest/globals';
|
2020-12-08 00:03:06 +00:00
|
|
|
import execa from 'execa';
|
2021-10-06 22:01:43 +00:00
|
|
|
import fs from 'fs';
|
2020-12-08 00:03:06 +00:00
|
|
|
import { getBinPathSync } from 'get-bin-path';
|
2021-10-06 22:01:43 +00:00
|
|
|
import path from 'path';
|
|
|
|
import { flatten } from 'ramda';
|
|
|
|
import { compact } from 'ramda-adjunct';
|
2020-12-08 00:03:06 +00:00
|
|
|
|
2021-10-06 22:01:43 +00:00
|
|
|
const binariesDirectory = '../insomnia-inso/binaries';
|
|
|
|
const npmPackageBinPath = getBinPathSync({ cwd: '../insomnia-inso' });
|
|
|
|
const binaries = fs.readdirSync(binariesDirectory).map(binary => path.join(binariesDirectory, binary));
|
2020-12-08 00:03:06 +00:00
|
|
|
|
2021-10-06 22:01:43 +00:00
|
|
|
type NestedArray<T> = (T | T[])[];
|
2020-12-08 00:03:06 +00:00
|
|
|
|
2021-10-06 22:01:43 +00:00
|
|
|
describe('should find binaries', () => {
|
|
|
|
it('should find the npm package bin', () => {
|
|
|
|
expect(npmPackageBinPath).not.toBeUndefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should find at least one single app binary', () => {
|
|
|
|
expect(binaries.length).toBeGreaterThanOrEqual(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
const srcInsoNedb = ['--src', 'fixtures/inso-nedb'];
|
|
|
|
|
|
|
|
describe.each(compact([npmPackageBinPath, ...binaries]))('inso with %s', binPath => {
|
|
|
|
const inso = (...args: NestedArray<string>) => execa.sync(binPath, flatten(args));
|
|
|
|
|
|
|
|
describe('run test', () => {
|
|
|
|
it('should not fail running tests', () => {
|
|
|
|
const { failed } = inso(
|
|
|
|
'run',
|
|
|
|
'test',
|
|
|
|
srcInsoNedb,
|
|
|
|
['--env', 'Dev'],
|
|
|
|
'Echo Test Suite',
|
2022-03-03 13:42:04 +00:00
|
|
|
'--verbose',
|
2021-10-06 22:01:43 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
expect(failed).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('generate config', () => {
|
|
|
|
it('should not fail generating config', () => {
|
|
|
|
const { failed } = inso(
|
|
|
|
'generate',
|
|
|
|
'config',
|
|
|
|
srcInsoNedb,
|
|
|
|
'Smoke Test API server 1.0.0',
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(failed).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('lint spec', () => {
|
|
|
|
it('should not fail linting spec', () => {
|
|
|
|
const { failed } = inso(
|
|
|
|
'lint',
|
|
|
|
'spec',
|
|
|
|
srcInsoNedb,
|
|
|
|
'Smoke Test API server 1.0.0',
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(failed).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('export spec', () => {
|
|
|
|
it('should not fail linting spec', () => {
|
|
|
|
const { failed } = inso(
|
|
|
|
'export',
|
|
|
|
'spec',
|
|
|
|
srcInsoNedb,
|
|
|
|
'Smoke Test API server 1.0.0',
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(failed).toBe(false);
|
|
|
|
});
|
2020-12-08 00:03:06 +00:00
|
|
|
});
|
|
|
|
});
|