mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-06 21:30:21 +03:00
test: .redocly.yaml config is applied
This commit is contained in:
parent
9c5e7ab1bd
commit
74c9e81f8d
9
.github/workflows/unit-tests.yml
vendored
9
.github/workflows/unit-tests.yml
vendored
|
@ -6,7 +6,8 @@ jobs:
|
||||||
build-and-unit:
|
build-and-unit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run bundle
|
- run: npm ci --prefix cli
|
||||||
- run: npm test
|
- run: npm run bundle
|
||||||
|
- run: npm test
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -28,7 +28,7 @@ bundles/
|
||||||
typings/*
|
typings/*
|
||||||
!typings/styled-patch.d.ts
|
!typings/styled-patch.d.ts
|
||||||
cli/index.js
|
cli/index.js
|
||||||
cli/__test__/*/**/redoc-static.html
|
cli/__test__/*/**/*.html
|
||||||
|
|
||||||
/benchmark/revisions
|
/benchmark/revisions
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,11 @@
|
||||||
import { spawnSync } from 'child_process';
|
import { spawnSync } from 'child_process';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
describe('build', () => {
|
describe('build', () => {
|
||||||
it('should use .redocly.yaml', () => {
|
it('should use .redocly.yaml', () => {
|
||||||
const r = spawnSync('node', ['../../../index.js', 'build', ' ../../../../demo/openapi.yaml'], {
|
|
||||||
cwd: __dirname,
|
|
||||||
shell: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const out = r.stdout.toString('utf-8');
|
|
||||||
const err = r.stderr.toString('utf-8');
|
|
||||||
const result = `${out}\n${err}`;
|
|
||||||
expect(result).toContain('Found .redocly.yaml and use option from features.openapi');
|
|
||||||
expect(result).toContain('bundled successfully');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should use inline options and ignore .redocly.yaml', () => {
|
|
||||||
const r = spawnSync(
|
const r = spawnSync(
|
||||||
'node',
|
'node',
|
||||||
[
|
['../../../index.js', 'build', ' ../../../../demo/openapi.yaml', '--output=redocTest.html'],
|
||||||
'../../../index.js',
|
|
||||||
'build',
|
|
||||||
' ../../../../demo/openapi.yaml',
|
|
||||||
'--options.disableSearch=true',
|
|
||||||
],
|
|
||||||
{
|
{
|
||||||
cwd: __dirname,
|
cwd: __dirname,
|
||||||
shell: true,
|
shell: true,
|
||||||
|
@ -32,7 +15,16 @@ describe('build', () => {
|
||||||
const out = r.stdout.toString('utf-8');
|
const out = r.stdout.toString('utf-8');
|
||||||
const err = r.stderr.toString('utf-8');
|
const err = r.stderr.toString('utf-8');
|
||||||
const result = `${out}\n${err}`;
|
const result = `${out}\n${err}`;
|
||||||
expect(result).not.toContain('Found .redocly.yaml and use option from features.openapi');
|
|
||||||
|
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 use options from features.openapi');
|
||||||
expect(result).toContain('bundled successfully');
|
expect(result).toContain('bundled successfully');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
34
cli/__test__/build/configRedoc/inlineOptions.test.ts
Normal file
34
cli/__test__/build/configRedoc/inlineOptions.test.ts
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import { spawnSync } from 'child_process';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
|
describe('build with inline options', () => {
|
||||||
|
it('should use inline options and ignore .redocly.yaml', () => {
|
||||||
|
const r = spawnSync(
|
||||||
|
'node',
|
||||||
|
[
|
||||||
|
'../../../index.js',
|
||||||
|
'build',
|
||||||
|
' ../../../../demo/openapi.yaml',
|
||||||
|
'--options.disableSearch="false" ',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
cwd: __dirname,
|
||||||
|
shell: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const out = r.stdout.toString('utf-8');
|
||||||
|
const err = r.stderr.toString('utf-8');
|
||||||
|
const result = `${out}\n${err}`;
|
||||||
|
expect(result).not.toContain('Found .redocly.yaml and use options from features.openapi');
|
||||||
|
expect(result).toContain('bundled successfully');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const redocStaticFile = readFileSync(`${__dirname}/redoc-static.html`, 'utf8');
|
||||||
|
expect(redocStaticFile).toContain('"options":{"disableSearch":"false"}');
|
||||||
|
expect(redocStaticFile).toContain('role="search"');
|
||||||
|
} catch (err) {
|
||||||
|
expect(err.toString()).toContain('"options":{"disableSearch":"false"}');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -455,7 +455,7 @@ function getObjectOrJSON(options) {
|
||||||
default:
|
default:
|
||||||
const configFile = findConfig();
|
const configFile = findConfig();
|
||||||
if (configFile) {
|
if (configFile) {
|
||||||
console.log(`Found ${configFile} and use option from features.openapi`);
|
console.log(`Found ${configFile} and use options from features.openapi`);
|
||||||
try {
|
try {
|
||||||
const config = parseYaml(readFileSync(configFile, 'utf-8')) as Config;
|
const config = parseYaml(readFileSync(configFile, 'utf-8')) as Config;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
"lint": "eslint --fix 'src/**/*.{js,ts,tsx}' --cache",
|
"lint": "eslint --fix 'src/**/*.{js,ts,tsx}' --cache",
|
||||||
"benchmark": "node ./benchmark/benchmark.js",
|
"benchmark": "node ./benchmark/benchmark.js",
|
||||||
"start:demo": "webpack serve --hot --config demo/webpack.config.ts --mode=development",
|
"start:demo": "webpack serve --hot --config demo/webpack.config.ts --mode=development",
|
||||||
"compile:cli": "cd cli/ && npm ci && cd ../ && tsc custom.d.ts cli/index.ts --target es6 --module commonjs --types yargs",
|
"compile:cli": "tsc custom.d.ts cli/index.ts --target es6 --module commonjs --types yargs",
|
||||||
"build:demo": "webpack --mode=production --config demo/webpack.config.ts",
|
"build:demo": "webpack --mode=production --config demo/webpack.config.ts",
|
||||||
"deploy:demo": "aws s3 sync demo/dist s3://production-redoc-demo --acl=public-read",
|
"deploy:demo": "aws s3 sync demo/dist s3://production-redoc-demo --acl=public-read",
|
||||||
"license-check": "license-checker --production --onlyAllow 'MIT;ISC;Apache-2.0;BSD;BSD-2-Clause;BSD-3-Clause;CC-BY-4.0;Python-2.0' --summary",
|
"license-check": "license-checker --production --onlyAllow 'MIT;ISC;Apache-2.0;BSD;BSD-2-Clause;BSD-3-Clause;CC-BY-4.0;Python-2.0' --summary",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user