redoc/cli/__test__/build/configRedoc/index.test.ts
Anastasiia Derymarko 1f417d67c6
feat: support .redocly.yaml for options for redoc-cli (#1981)
Co-authored-by: Anastasiia Derymarko < anastasiia@redocly.com>
Co-authored-by: Adam Altman <adam@redoc.ly>
Co-authored-by: Ivana Isadora Devcic <33730345+skadinna@users.noreply.github.com>
2022-05-11 08:58:24 +03:00

31 lines
970 B
TypeScript

import { spawnSync } from 'child_process';
import { readFileSync } from 'fs';
describe('build', () => {
it('should use .redocly.yaml', () => {
const r = spawnSync(
'node',
['../../../index.js', 'build', ' ../../../../demo/openapi.yaml', '--output=redocTest.html'],
{
cwd: __dirname,
shell: true,
},
);
const out = r.stdout.toString('utf-8');
const err = r.stderr.toString('utf-8');
const result = `${out}\n${err}`;
try {
const redocStaticFile = readFileSync(`${__dirname}/redocTest.html`, 'utf8');
expect(redocStaticFile).toContain('"options":{"disableSearch":true}');
expect(redocStaticFile).not.toContain('role="search"');
} catch (err) {
expect(err.toString()).toContain('{"options":{"disableSearch":"true"}');
}
expect(result).toContain('Found .redocly.yaml and using features.openapi options');
expect(result).toContain('bundled successfully');
});
});