@redocly/cli 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/lib/__mocks__/@redocly/openapi-core.d.ts +1 -0
- package/lib/__mocks__/@redocly/openapi-core.js +4 -3
- package/lib/__mocks__/utils.d.ts +2 -0
- package/lib/__mocks__/utils.js +3 -1
- package/lib/__tests__/commands/build-docs.test.js +2 -2
- package/lib/__tests__/commands/bundle.test.js +7 -7
- package/lib/__tests__/commands/join.test.js +25 -18
- package/lib/__tests__/commands/lint.test.js +15 -15
- package/lib/__tests__/commands/push-region.test.js +2 -2
- package/lib/__tests__/commands/push.test.js +30 -30
- package/lib/__tests__/fetch-with-timeout.test.js +2 -2
- package/lib/__tests__/utils.test.js +63 -32
- package/lib/__tests__/wrapper.test.js +3 -3
- package/lib/assert-node-version.js +1 -1
- package/lib/commands/build-docs/index.js +9 -9
- package/lib/commands/build-docs/types.d.ts +2 -2
- package/lib/commands/build-docs/utils.js +10 -10
- package/lib/commands/bundle.d.ts +1 -1
- package/lib/commands/bundle.js +25 -25
- package/lib/commands/join.d.ts +1 -1
- package/lib/commands/join.js +49 -48
- package/lib/commands/lint.d.ts +1 -1
- package/lib/commands/lint.js +22 -22
- package/lib/commands/login.d.ts +1 -1
- package/lib/commands/login.js +3 -3
- package/lib/commands/preview-docs/index.d.ts +1 -1
- package/lib/commands/preview-docs/index.js +7 -7
- package/lib/commands/preview-docs/preview-server/hot.js +19 -2
- package/lib/commands/preview-docs/preview-server/preview-server.js +15 -14
- package/lib/commands/preview-docs/preview-server/server.d.ts +3 -1
- package/lib/commands/preview-docs/preview-server/server.js +2 -2
- package/lib/commands/push.d.ts +2 -2
- package/lib/commands/push.js +31 -31
- package/lib/commands/split/__tests__/index.test.js +9 -9
- package/lib/commands/split/index.d.ts +2 -2
- package/lib/commands/split/index.js +41 -40
- package/lib/commands/split/types.d.ts +2 -2
- package/lib/commands/split/types.js +2 -2
- package/lib/commands/stats.d.ts +1 -1
- package/lib/commands/stats.js +9 -9
- package/lib/fetch-with-timeout.js +5 -2
- package/lib/index.js +11 -12
- package/lib/types.d.ts +6 -6
- package/lib/update-version-notifier.js +18 -18
- package/lib/utils.d.ts +6 -3
- package/lib/utils.js +66 -38
- package/lib/wrapper.js +5 -5
- package/package.json +3 -3
- package/src/__mocks__/@redocly/openapi-core.ts +1 -0
- package/src/__mocks__/utils.ts +2 -0
- package/src/__tests__/commands/join.test.ts +37 -7
- package/src/__tests__/utils.test.ts +45 -1
- package/src/commands/join.ts +8 -3
- package/src/commands/preview-docs/preview-server/hot.js +19 -2
- package/src/commands/preview-docs/preview-server/preview-server.ts +6 -4
- package/src/commands/preview-docs/preview-server/server.ts +2 -2
- package/src/commands/split/__tests__/index.test.ts +14 -5
- package/src/commands/split/index.ts +25 -17
- package/src/fetch-with-timeout.ts +3 -0
- package/src/index.ts +0 -1
- package/src/utils.ts +40 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @redocly/cli
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added `recommended-strict` ruleset which uses the same rules as `recommended` but with the severity level set to `error` for all rules.
|
|
8
|
+
- Add JSON output support to the `split` and `join` commands.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- The `--host/-h` argument in the `preview-docs` command is now also used by the WebSocket server for hot reloading.
|
|
13
|
+
- Updated @redocly/openapi-core to v1.4.0.
|
|
14
|
+
|
|
3
15
|
## 1.3.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -63,6 +63,7 @@ export declare const bundleDocument: jest.Mock<Promise<{
|
|
|
63
63
|
}>, []>;
|
|
64
64
|
export declare const detectSpec: jest.Mock<any, any>;
|
|
65
65
|
export declare const isAbsoluteUrl: jest.Mock<any, any>;
|
|
66
|
+
export declare const stringifyYaml: jest.Mock<any, [data: any]>;
|
|
66
67
|
export declare class BaseResolver {
|
|
67
68
|
cache: Map<string, Promise<Document | ResolveError>>;
|
|
68
69
|
getFiles: jest.Mock<any, any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Oas3Operations = exports.SpecVersion = exports.YamlParseError = exports.ResolveError = exports.BaseResolver = exports.isAbsoluteUrl = exports.detectSpec = exports.bundleDocument = exports.doesYamlFileExist = exports.findConfig = exports.slash = exports.formatProblems = exports.getTotals = exports.bundle = exports.lint = exports.getMergedConfig = exports.loadConfig = exports.RedoclyClient = exports.__redoclyClient = void 0;
|
|
3
|
+
exports.Oas3Operations = exports.SpecVersion = exports.YamlParseError = exports.ResolveError = exports.BaseResolver = exports.stringifyYaml = exports.isAbsoluteUrl = exports.detectSpec = exports.bundleDocument = exports.doesYamlFileExist = exports.findConfig = exports.slash = exports.formatProblems = exports.getTotals = exports.bundle = exports.lint = exports.getMergedConfig = exports.loadConfig = exports.RedoclyClient = exports.__redoclyClient = void 0;
|
|
4
4
|
const config_1 = require("./../../__tests__/fixtures/config");
|
|
5
5
|
const documents_1 = require("../documents");
|
|
6
6
|
exports.__redoclyClient = {
|
|
@@ -30,6 +30,7 @@ exports.doesYamlFileExist = jest.fn();
|
|
|
30
30
|
exports.bundleDocument = jest.fn(() => Promise.resolve({ problems: {} }));
|
|
31
31
|
exports.detectSpec = jest.fn();
|
|
32
32
|
exports.isAbsoluteUrl = jest.fn();
|
|
33
|
+
exports.stringifyYaml = jest.fn((data) => data);
|
|
33
34
|
class BaseResolver {
|
|
34
35
|
constructor() {
|
|
35
36
|
this.cache = new Map();
|
|
@@ -66,7 +67,7 @@ var SpecVersion;
|
|
|
66
67
|
SpecVersion["OAS3_0"] = "oas3_0";
|
|
67
68
|
SpecVersion["OAS3_1"] = "oas3_1";
|
|
68
69
|
SpecVersion["Async2"] = "async2";
|
|
69
|
-
})(SpecVersion
|
|
70
|
+
})(SpecVersion || (exports.SpecVersion = SpecVersion = {}));
|
|
70
71
|
var Oas3Operations;
|
|
71
72
|
(function (Oas3Operations) {
|
|
72
73
|
Oas3Operations["get"] = "get";
|
|
@@ -77,4 +78,4 @@ var Oas3Operations;
|
|
|
77
78
|
Oas3Operations["head"] = "head";
|
|
78
79
|
Oas3Operations["patch"] = "patch";
|
|
79
80
|
Oas3Operations["trace"] = "trace";
|
|
80
|
-
})(Oas3Operations
|
|
81
|
+
})(Oas3Operations || (exports.Oas3Operations = Oas3Operations = {}));
|
package/lib/__mocks__/utils.d.ts
CHANGED
|
@@ -37,3 +37,5 @@ export declare const loadConfigAndHandleErrors: jest.Mock<{
|
|
|
37
37
|
}, []>;
|
|
38
38
|
export declare const checkIfRulesetExist: jest.Mock<any, any>;
|
|
39
39
|
export declare const sortTopLevelKeysForOas: jest.Mock<any, [document: any]>;
|
|
40
|
+
export declare const getAndValidateFileExtension: jest.Mock<string | undefined, [fileName: string]>;
|
|
41
|
+
export declare const writeToFileByExtension: jest.Mock<any, any>;
|
package/lib/__mocks__/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sortTopLevelKeysForOas = exports.checkIfRulesetExist = exports.loadConfigAndHandleErrors = exports.writeYaml = exports.exitWithError = exports.handleError = exports.getOutputFileName = exports.printLintTotals = exports.printUnusedWarnings = exports.printExecutionTime = exports.getExecutionTime = exports.pluralize = exports.slash = exports.dumpBundle = exports.getFallbackApisOrExit = void 0;
|
|
3
|
+
exports.writeToFileByExtension = exports.getAndValidateFileExtension = exports.sortTopLevelKeysForOas = exports.checkIfRulesetExist = exports.loadConfigAndHandleErrors = exports.writeYaml = exports.exitWithError = exports.handleError = exports.getOutputFileName = exports.printLintTotals = exports.printUnusedWarnings = exports.printExecutionTime = exports.getExecutionTime = exports.pluralize = exports.slash = exports.dumpBundle = exports.getFallbackApisOrExit = void 0;
|
|
4
4
|
const config_1 = require("../__tests__/fixtures/config");
|
|
5
5
|
exports.getFallbackApisOrExit = jest.fn((entrypoints) => entrypoints.map((path) => ({ path })));
|
|
6
6
|
exports.dumpBundle = jest.fn(() => '');
|
|
@@ -17,3 +17,5 @@ exports.writeYaml = jest.fn();
|
|
|
17
17
|
exports.loadConfigAndHandleErrors = jest.fn(() => config_1.ConfigFixture);
|
|
18
18
|
exports.checkIfRulesetExist = jest.fn();
|
|
19
19
|
exports.sortTopLevelKeysForOas = jest.fn((document) => document);
|
|
20
|
+
exports.getAndValidateFileExtension = jest.fn((fileName) => fileName.split('.').pop());
|
|
21
|
+
exports.writeToFileByExtension = jest.fn();
|
|
@@ -33,14 +33,14 @@ jest.mock('handlebars', () => ({
|
|
|
33
33
|
}));
|
|
34
34
|
describe('build-docs', () => {
|
|
35
35
|
it('should return correct html and call function for ssr', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
const result = yield utils_1.getPageHTML({}, '../some-path/openapi.yaml', Object.assign(Object.assign({}, config), { redocCurrentVersion: '2.0.0' }));
|
|
36
|
+
const result = yield (0, utils_1.getPageHTML)({}, '../some-path/openapi.yaml', Object.assign(Object.assign({}, config), { redocCurrentVersion: '2.0.0' }));
|
|
37
37
|
expect(server_1.renderToString).toBeCalledTimes(1);
|
|
38
38
|
expect(redoc_1.createStore).toBeCalledTimes(1);
|
|
39
39
|
expect(result).toBe('<html></html>');
|
|
40
40
|
}));
|
|
41
41
|
it('should work correctly when calling handlerBuildCommand', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
42
|
const processExitMock = jest.spyOn(process, 'exit').mockImplementation();
|
|
43
|
-
yield build_docs_1.handlerBuildCommand({
|
|
43
|
+
yield (0, build_docs_1.handlerBuildCommand)({
|
|
44
44
|
o: '',
|
|
45
45
|
title: 'test',
|
|
46
46
|
disableGoogleFont: false,
|
|
@@ -34,7 +34,7 @@ describe('bundle', () => {
|
|
|
34
34
|
});
|
|
35
35
|
it('bundles definitions w/o linting', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
36
|
const apis = ['foo.yaml', 'bar.yaml'];
|
|
37
|
-
yield wrapper_1.commandWrapper(bundle_1.handleBundle)({
|
|
37
|
+
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
38
38
|
apis,
|
|
39
39
|
ext: 'yaml',
|
|
40
40
|
format: 'codeframe',
|
|
@@ -44,7 +44,7 @@ describe('bundle', () => {
|
|
|
44
44
|
}));
|
|
45
45
|
it('exits with code 0 when bundles definitions', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
46
|
const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
|
|
47
|
-
yield wrapper_1.commandWrapper(bundle_1.handleBundle)({
|
|
47
|
+
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
48
48
|
apis,
|
|
49
49
|
ext: 'yaml',
|
|
50
50
|
format: 'codeframe',
|
|
@@ -59,7 +59,7 @@ describe('bundle', () => {
|
|
|
59
59
|
warnings: 0,
|
|
60
60
|
ignored: 0,
|
|
61
61
|
});
|
|
62
|
-
yield wrapper_1.commandWrapper(bundle_1.handleBundle)({
|
|
62
|
+
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
63
63
|
apis,
|
|
64
64
|
ext: 'yaml',
|
|
65
65
|
format: 'codeframe',
|
|
@@ -70,7 +70,7 @@ describe('bundle', () => {
|
|
|
70
70
|
}));
|
|
71
71
|
it('exits with code 0 when bundles definitions w/linting w/o errors', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
72
|
const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
|
|
73
|
-
yield wrapper_1.commandWrapper(bundle_1.handleBundle)({
|
|
73
|
+
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
74
74
|
apis,
|
|
75
75
|
ext: 'yaml',
|
|
76
76
|
format: 'codeframe',
|
|
@@ -86,7 +86,7 @@ describe('bundle', () => {
|
|
|
86
86
|
warnings: 0,
|
|
87
87
|
ignored: 0,
|
|
88
88
|
});
|
|
89
|
-
yield wrapper_1.commandWrapper(bundle_1.handleBundle)({
|
|
89
|
+
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
90
90
|
apis,
|
|
91
91
|
ext: 'yaml',
|
|
92
92
|
format: 'codeframe',
|
|
@@ -101,7 +101,7 @@ describe('bundle', () => {
|
|
|
101
101
|
openapi_core_1.bundle.mockImplementationOnce(() => {
|
|
102
102
|
throw new Error('Invalid definition');
|
|
103
103
|
});
|
|
104
|
-
yield wrapper_1.commandWrapper(bundle_1.handleBundle)({
|
|
104
|
+
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
105
105
|
apis,
|
|
106
106
|
ext: 'json',
|
|
107
107
|
format: 'codeframe',
|
|
@@ -117,7 +117,7 @@ describe('bundle', () => {
|
|
|
117
117
|
warnings: 0,
|
|
118
118
|
ignored: 0,
|
|
119
119
|
});
|
|
120
|
-
yield wrapper_1.commandWrapper(bundle_1.handleBundle)({
|
|
120
|
+
yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
|
|
121
121
|
apis,
|
|
122
122
|
ext: 'yaml',
|
|
123
123
|
format: 'codeframe',
|
|
@@ -21,11 +21,11 @@ describe('handleJoin fails', () => {
|
|
|
21
21
|
const colloreteYellowMock = colorette_1.yellow;
|
|
22
22
|
colloreteYellowMock.mockImplementation((string) => string);
|
|
23
23
|
it('should call exitWithError because only one entrypoint', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
-
yield join_1.handleJoin({ apis: ['first.yaml'] }, {}, 'cli-version');
|
|
24
|
+
yield (0, join_1.handleJoin)({ apis: ['first.yaml'] }, {}, 'cli-version');
|
|
25
25
|
expect(utils_1.exitWithError).toHaveBeenCalledWith(`At least 2 apis should be provided. \n\n`);
|
|
26
26
|
}));
|
|
27
27
|
it('should call exitWithError because passed all 3 options for tags', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
-
yield join_1.handleJoin({
|
|
28
|
+
yield (0, join_1.handleJoin)({
|
|
29
29
|
apis: ['first.yaml', 'second.yaml'],
|
|
30
30
|
'prefix-tags-with-info-prop': 'something',
|
|
31
31
|
'without-x-tag-groups': true,
|
|
@@ -34,7 +34,7 @@ describe('handleJoin fails', () => {
|
|
|
34
34
|
expect(utils_1.exitWithError).toHaveBeenCalledWith(`You use prefix-tags-with-filename, prefix-tags-with-info-prop, without-x-tag-groups together.\nPlease choose only one! \n\n`);
|
|
35
35
|
}));
|
|
36
36
|
it('should call exitWithError because passed all 2 options for tags', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
yield join_1.handleJoin({
|
|
37
|
+
yield (0, join_1.handleJoin)({
|
|
38
38
|
apis: ['first.yaml', 'second.yaml'],
|
|
39
39
|
'without-x-tag-groups': true,
|
|
40
40
|
'prefix-tags-with-filename': true,
|
|
@@ -42,7 +42,7 @@ describe('handleJoin fails', () => {
|
|
|
42
42
|
expect(utils_1.exitWithError).toHaveBeenCalledWith(`You use prefix-tags-with-filename, without-x-tag-groups together.\nPlease choose only one! \n\n`);
|
|
43
43
|
}));
|
|
44
44
|
it('should call exitWithError because Only OpenAPI 3.0 and OpenAPI 3.1 are supported', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
-
yield join_1.handleJoin({
|
|
45
|
+
yield (0, join_1.handleJoin)({
|
|
46
46
|
apis: ['first.yaml', 'second.yaml'],
|
|
47
47
|
}, config_1.ConfigFixture, 'cli-version');
|
|
48
48
|
expect(utils_1.exitWithError).toHaveBeenCalledWith('Only OpenAPI 3.0 and OpenAPI 3.1 are supported: undefined \n\n');
|
|
@@ -51,50 +51,57 @@ describe('handleJoin fails', () => {
|
|
|
51
51
|
openapi_core_1.detectSpec
|
|
52
52
|
.mockImplementationOnce(() => 'oas3_0')
|
|
53
53
|
.mockImplementationOnce(() => 'oas3_1');
|
|
54
|
-
yield join_1.handleJoin({
|
|
54
|
+
yield (0, join_1.handleJoin)({
|
|
55
55
|
apis: ['first.yaml', 'second.yaml'],
|
|
56
56
|
}, config_1.ConfigFixture, 'cli-version');
|
|
57
57
|
expect(utils_1.exitWithError).toHaveBeenCalledWith('All APIs must use the same OpenAPI version: undefined \n\n');
|
|
58
58
|
}));
|
|
59
|
-
it('should call
|
|
59
|
+
it('should call writeToFileByExtension function', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
60
|
openapi_core_1.detectSpec.mockReturnValue('oas3_0');
|
|
61
|
-
yield join_1.handleJoin({
|
|
61
|
+
yield (0, join_1.handleJoin)({
|
|
62
62
|
apis: ['first.yaml', 'second.yaml'],
|
|
63
63
|
}, config_1.ConfigFixture, 'cli-version');
|
|
64
|
-
expect(utils_1.
|
|
64
|
+
expect(utils_1.writeToFileByExtension).toHaveBeenCalledWith(expect.any(Object), 'openapi.yaml', expect.any(Boolean));
|
|
65
65
|
}));
|
|
66
|
-
it('should call
|
|
66
|
+
it('should call writeToFileByExtension function for OpenAPI 3.1', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
67
|
openapi_core_1.detectSpec.mockReturnValue('oas3_1');
|
|
68
|
-
yield join_1.handleJoin({
|
|
68
|
+
yield (0, join_1.handleJoin)({
|
|
69
69
|
apis: ['first.yaml', 'second.yaml'],
|
|
70
70
|
}, config_1.ConfigFixture, 'cli-version');
|
|
71
|
-
expect(utils_1.
|
|
71
|
+
expect(utils_1.writeToFileByExtension).toHaveBeenCalledWith(expect.any(Object), 'openapi.yaml', expect.any(Boolean));
|
|
72
72
|
}));
|
|
73
|
-
it('should call
|
|
73
|
+
it('should call writeToFileByExtension function with custom output file', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
74
|
openapi_core_1.detectSpec.mockReturnValue('oas3_0');
|
|
75
|
-
yield join_1.handleJoin({
|
|
75
|
+
yield (0, join_1.handleJoin)({
|
|
76
76
|
apis: ['first.yaml', 'second.yaml'],
|
|
77
77
|
output: 'output.yml',
|
|
78
78
|
}, config_1.ConfigFixture, 'cli-version');
|
|
79
|
-
expect(utils_1.
|
|
79
|
+
expect(utils_1.writeToFileByExtension).toHaveBeenCalledWith(expect.any(Object), 'output.yml', expect.any(Boolean));
|
|
80
|
+
}));
|
|
81
|
+
it('should call writeToFileByExtension function with json file extension', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
+
openapi_core_1.detectSpec.mockReturnValue('oas3_0');
|
|
83
|
+
yield (0, join_1.handleJoin)({
|
|
84
|
+
apis: ['first.json', 'second.yaml'],
|
|
85
|
+
}, config_1.ConfigFixture, 'cli-version');
|
|
86
|
+
expect(utils_1.writeToFileByExtension).toHaveBeenCalledWith(expect.any(Object), 'openapi.json', expect.any(Boolean));
|
|
80
87
|
}));
|
|
81
88
|
it('should call skipDecorators and skipPreprocessors', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
89
|
openapi_core_1.detectSpec.mockReturnValue('oas3_0');
|
|
83
|
-
yield join_1.handleJoin({
|
|
90
|
+
yield (0, join_1.handleJoin)({
|
|
84
91
|
apis: ['first.yaml', 'second.yaml'],
|
|
85
92
|
}, config_1.ConfigFixture, 'cli-version');
|
|
86
|
-
const config = openapi_core_2.loadConfig();
|
|
93
|
+
const config = (0, openapi_core_2.loadConfig)();
|
|
87
94
|
expect(config.styleguide.skipDecorators).toHaveBeenCalled();
|
|
88
95
|
expect(config.styleguide.skipPreprocessors).toHaveBeenCalled();
|
|
89
96
|
}));
|
|
90
97
|
it('should not call skipDecorators and skipPreprocessors', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
98
|
openapi_core_1.detectSpec.mockReturnValue('oas3_0');
|
|
92
|
-
yield join_1.handleJoin({
|
|
99
|
+
yield (0, join_1.handleJoin)({
|
|
93
100
|
apis: ['first.yaml', 'second.yaml'],
|
|
94
101
|
decorate: true,
|
|
95
102
|
preprocess: true,
|
|
96
103
|
}, config_1.ConfigFixture, 'cli-version');
|
|
97
|
-
const config = openapi_core_2.loadConfig();
|
|
104
|
+
const config = (0, openapi_core_2.loadConfig)();
|
|
98
105
|
expect(config.styleguide.skipDecorators).not.toHaveBeenCalled();
|
|
99
106
|
expect(config.styleguide.skipPreprocessors).not.toHaveBeenCalled();
|
|
100
107
|
}));
|
|
@@ -47,11 +47,11 @@ describe('handleLint', () => {
|
|
|
47
47
|
});
|
|
48
48
|
describe('loadConfig and getEnrtypoints stage', () => {
|
|
49
49
|
it('should fail if config file does not exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(Object.assign(Object.assign({}, argvMock), { config: 'config.yaml' }));
|
|
50
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(Object.assign(Object.assign({}, argvMock), { config: 'config.yaml' }));
|
|
51
51
|
expect(utils_1.exitWithError).toHaveBeenCalledWith('Please, provide valid path to the configuration file');
|
|
52
52
|
}));
|
|
53
53
|
it('should call loadConfigAndHandleErrors and getFallbackApisOrExit', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(argvMock);
|
|
54
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(argvMock);
|
|
55
55
|
expect(utils_1.loadConfigAndHandleErrors).toHaveBeenCalledWith({
|
|
56
56
|
configPath: undefined,
|
|
57
57
|
customExtends: undefined,
|
|
@@ -60,7 +60,7 @@ describe('handleLint', () => {
|
|
|
60
60
|
expect(utils_1.getFallbackApisOrExit).toHaveBeenCalled();
|
|
61
61
|
}));
|
|
62
62
|
it('should call loadConfig with args if such exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(Object.assign(Object.assign({}, argvMock), { config: 'redocly.yaml', extends: ['some/path'] }));
|
|
63
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(Object.assign(Object.assign({}, argvMock), { config: 'redocly.yaml', extends: ['some/path'] }));
|
|
64
64
|
expect(utils_1.loadConfigAndHandleErrors).toHaveBeenCalledWith({
|
|
65
65
|
configPath: 'redocly.yaml',
|
|
66
66
|
customExtends: ['some/path'],
|
|
@@ -68,35 +68,35 @@ describe('handleLint', () => {
|
|
|
68
68
|
});
|
|
69
69
|
}));
|
|
70
70
|
it('should call mergedConfig with clear ignore if `generate-ignore-file` argv', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(Object.assign(Object.assign({}, argvMock), { 'generate-ignore-file': true }));
|
|
71
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(Object.assign(Object.assign({}, argvMock), { 'generate-ignore-file': true }));
|
|
72
72
|
expect(getMergedConfigMock).toHaveBeenCalled();
|
|
73
73
|
}));
|
|
74
74
|
it('should check if ruleset exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(argvMock);
|
|
75
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(argvMock);
|
|
76
76
|
expect(utils_1.checkIfRulesetExist).toHaveBeenCalledTimes(1);
|
|
77
77
|
}));
|
|
78
78
|
it('should fail if apis not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(Object.assign(Object.assign({}, argvMock), { apis: [] }));
|
|
79
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(Object.assign(Object.assign({}, argvMock), { apis: [] }));
|
|
80
80
|
expect(utils_1.getFallbackApisOrExit).toHaveBeenCalledTimes(1);
|
|
81
81
|
expect(utils_1.exitWithError).toHaveBeenCalledWith('No APIs were provided');
|
|
82
82
|
}));
|
|
83
83
|
});
|
|
84
84
|
describe('loop through entrypoints and lint stage', () => {
|
|
85
85
|
it('should call getMergedConfig and lint ', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(argvMock);
|
|
86
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(argvMock);
|
|
87
87
|
expect(perf_hooks_1.performance.now).toHaveBeenCalled();
|
|
88
88
|
expect(getMergedConfigMock).toHaveBeenCalled();
|
|
89
89
|
expect(openapi_core_1.lint).toHaveBeenCalled();
|
|
90
90
|
}));
|
|
91
91
|
it('should call skipRules,skipPreprocessors and addIgnore with argv', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
92
|
openapi_core_1.lint.mockResolvedValueOnce(['problem']);
|
|
93
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(Object.assign(Object.assign({}, argvMock), { 'skip-preprocessor': ['preprocessor'], 'skip-rule': ['rule'], 'generate-ignore-file': true }));
|
|
93
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(Object.assign(Object.assign({}, argvMock), { 'skip-preprocessor': ['preprocessor'], 'skip-rule': ['rule'], 'generate-ignore-file': true }));
|
|
94
94
|
expect(config_1.ConfigFixture.styleguide.skipRules).toHaveBeenCalledWith(['rule']);
|
|
95
95
|
expect(config_1.ConfigFixture.styleguide.skipPreprocessors).toHaveBeenCalledWith(['preprocessor']);
|
|
96
96
|
}));
|
|
97
97
|
it('should call formatProblems and getExecutionTime with argv', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
98
|
openapi_core_1.lint.mockResolvedValueOnce(['problem']);
|
|
99
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(Object.assign(Object.assign({}, argvMock), { 'max-problems': 2, format: 'stylish' }));
|
|
99
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(Object.assign(Object.assign({}, argvMock), { 'max-problems': 2, format: 'stylish' }));
|
|
100
100
|
expect(openapi_core_1.getTotals).toHaveBeenCalledWith(['problem']);
|
|
101
101
|
expect(openapi_core_1.formatProblems).toHaveBeenCalledWith(['problem'], {
|
|
102
102
|
format: 'stylish',
|
|
@@ -108,26 +108,26 @@ describe('handleLint', () => {
|
|
|
108
108
|
}));
|
|
109
109
|
it('should catch error in handleError if something fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
110
|
openapi_core_1.lint.mockRejectedValueOnce('error');
|
|
111
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(argvMock);
|
|
111
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(argvMock);
|
|
112
112
|
expect(utils_1.handleError).toHaveBeenCalledWith('error', 'openapi.yaml');
|
|
113
113
|
}));
|
|
114
114
|
});
|
|
115
115
|
describe('erros and warning handle after lint stage', () => {
|
|
116
116
|
it('should call printLintTotals and printLintTotals', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(argvMock);
|
|
117
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(argvMock);
|
|
118
118
|
expect(utils_1.printUnusedWarnings).toHaveBeenCalled();
|
|
119
119
|
}));
|
|
120
120
|
it('should call exit with 0 if no errors', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
121
|
utils_1.loadConfigAndHandleErrors.mockImplementation(() => {
|
|
122
122
|
return Object.assign({}, config_1.ConfigFixture);
|
|
123
123
|
});
|
|
124
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(argvMock);
|
|
124
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(argvMock);
|
|
125
125
|
yield (exitCb === null || exitCb === void 0 ? void 0 : exitCb());
|
|
126
126
|
expect(processExitMock).toHaveBeenCalledWith(0);
|
|
127
127
|
}));
|
|
128
128
|
it('should exit with 1 if total errors > 0', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
129
129
|
openapi_core_1.getTotals.mockReturnValueOnce({ errors: 1 });
|
|
130
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(argvMock);
|
|
130
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(argvMock);
|
|
131
131
|
yield (exitCb === null || exitCb === void 0 ? void 0 : exitCb());
|
|
132
132
|
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
133
133
|
}));
|
|
@@ -142,8 +142,8 @@ describe('handleLint', () => {
|
|
|
142
142
|
},
|
|
143
143
|
};
|
|
144
144
|
});
|
|
145
|
-
yield wrapper_1.commandWrapper(lint_1.handleLint)(argvMock);
|
|
146
|
-
expect(process.stderr.write).toHaveBeenCalledWith(`No configurations were provided -- using built in ${colorette_1.blue('recommended')} configuration by default.\n\n`);
|
|
145
|
+
yield (0, wrapper_1.commandWrapper)(lint_1.handleLint)(argvMock);
|
|
146
|
+
expect(process.stderr.write).toHaveBeenCalledWith(`No configurations were provided -- using built in ${(0, colorette_1.blue)('recommended')} configuration by default.\n\n`);
|
|
147
147
|
}));
|
|
148
148
|
});
|
|
149
149
|
});
|
|
@@ -33,7 +33,7 @@ describe('push-with-region', () => {
|
|
|
33
33
|
});
|
|
34
34
|
it('should call login with default domain when region is US', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
35
|
redoclyClient.domain = 'redoc.ly';
|
|
36
|
-
yield push_1.handlePush({
|
|
36
|
+
yield (0, push_1.handlePush)({
|
|
37
37
|
upsert: true,
|
|
38
38
|
api: 'spec.json',
|
|
39
39
|
destination: '@org/my-api@1.0.0',
|
|
@@ -44,7 +44,7 @@ describe('push-with-region', () => {
|
|
|
44
44
|
}));
|
|
45
45
|
it('should call login with EU domain when region is EU', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
46
|
redoclyClient.domain = 'eu.redocly.com';
|
|
47
|
-
yield push_1.handlePush({
|
|
47
|
+
yield (0, push_1.handlePush)({
|
|
48
48
|
upsert: true,
|
|
49
49
|
api: 'spec.json',
|
|
50
50
|
destination: '@org/my-api@1.0.0',
|
|
@@ -31,7 +31,7 @@ describe('push', () => {
|
|
|
31
31
|
jest.spyOn(process.stdout, 'write').mockImplementation(() => true);
|
|
32
32
|
});
|
|
33
33
|
it('pushes definition', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
yield push_1.handlePush({
|
|
34
|
+
yield (0, push_1.handlePush)({
|
|
35
35
|
upsert: true,
|
|
36
36
|
api: 'spec.json',
|
|
37
37
|
destination: '@org/my-api@1.0.0',
|
|
@@ -56,7 +56,7 @@ describe('push', () => {
|
|
|
56
56
|
});
|
|
57
57
|
}));
|
|
58
58
|
it('fails if jobId value is an empty string', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
-
yield push_1.handlePush({
|
|
59
|
+
yield (0, push_1.handlePush)({
|
|
60
60
|
upsert: true,
|
|
61
61
|
api: 'spec.json',
|
|
62
62
|
destination: '@org/my-api@1.0.0',
|
|
@@ -68,7 +68,7 @@ describe('push', () => {
|
|
|
68
68
|
expect(utils_1.exitWithError).toBeCalledTimes(1);
|
|
69
69
|
}));
|
|
70
70
|
it('fails if batchSize value is less than 2', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
-
yield push_1.handlePush({
|
|
71
|
+
yield (0, push_1.handlePush)({
|
|
72
72
|
upsert: true,
|
|
73
73
|
api: 'spec.json',
|
|
74
74
|
destination: '@org/my-api@1.0.0',
|
|
@@ -84,7 +84,7 @@ describe('push', () => {
|
|
|
84
84
|
fs.statSync.mockImplementation(() => {
|
|
85
85
|
return { isDirectory: () => false, size: 10 };
|
|
86
86
|
});
|
|
87
|
-
yield push_1.handlePush({
|
|
87
|
+
yield (0, push_1.handlePush)({
|
|
88
88
|
upsert: true,
|
|
89
89
|
api: 'spec.json',
|
|
90
90
|
destination: '@org/my-api@1.0.0',
|
|
@@ -103,7 +103,7 @@ describe('push', () => {
|
|
|
103
103
|
expect(redoclyClient.registryApi.prepareFileUpload).toBeCalledTimes(3);
|
|
104
104
|
}));
|
|
105
105
|
it('push should fail if organization not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
-
yield push_1.handlePush({
|
|
106
|
+
yield (0, push_1.handlePush)({
|
|
107
107
|
upsert: true,
|
|
108
108
|
api: 'spec.json',
|
|
109
109
|
destination: 'test@v1',
|
|
@@ -117,7 +117,7 @@ describe('push', () => {
|
|
|
117
117
|
}));
|
|
118
118
|
it('push should work with organization in config', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
119
119
|
const mockConfig = Object.assign(Object.assign({}, config_1.ConfigFixture), { organization: 'test_org' });
|
|
120
|
-
yield push_1.handlePush({
|
|
120
|
+
yield (0, push_1.handlePush)({
|
|
121
121
|
upsert: true,
|
|
122
122
|
api: 'spec.json',
|
|
123
123
|
destination: 'my-api@1.0.0',
|
|
@@ -142,7 +142,7 @@ describe('push', () => {
|
|
|
142
142
|
}));
|
|
143
143
|
it('push should work if destination not provided but api in config is provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
144
|
const mockConfig = Object.assign(Object.assign({}, config_1.ConfigFixture), { organization: 'test_org', apis: { 'my-api@1.0.0': { root: 'path' } } });
|
|
145
|
-
yield push_1.handlePush({
|
|
145
|
+
yield (0, push_1.handlePush)({
|
|
146
146
|
upsert: true,
|
|
147
147
|
branchName: 'test',
|
|
148
148
|
public: true,
|
|
@@ -153,7 +153,7 @@ describe('push', () => {
|
|
|
153
153
|
}));
|
|
154
154
|
it('push should fail if apis not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
155
|
const mockConfig = { organization: 'test_org', apis: {} };
|
|
156
|
-
yield push_1.handlePush({
|
|
156
|
+
yield (0, push_1.handlePush)({
|
|
157
157
|
upsert: true,
|
|
158
158
|
branchName: 'test',
|
|
159
159
|
public: true,
|
|
@@ -165,7 +165,7 @@ describe('push', () => {
|
|
|
165
165
|
}));
|
|
166
166
|
it('push should fail if destination not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
167
167
|
const mockConfig = { organization: 'test_org', apis: {} };
|
|
168
|
-
yield push_1.handlePush({
|
|
168
|
+
yield (0, push_1.handlePush)({
|
|
169
169
|
upsert: true,
|
|
170
170
|
api: 'api.yaml',
|
|
171
171
|
branchName: 'test',
|
|
@@ -178,7 +178,7 @@ describe('push', () => {
|
|
|
178
178
|
}));
|
|
179
179
|
it('push should fail if destination format is not valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
180
180
|
const mockConfig = { organization: 'test_org', apis: {} };
|
|
181
|
-
yield push_1.handlePush({
|
|
181
|
+
yield (0, push_1.handlePush)({
|
|
182
182
|
upsert: true,
|
|
183
183
|
destination: 'name/v1',
|
|
184
184
|
branchName: 'test',
|
|
@@ -186,12 +186,12 @@ describe('push', () => {
|
|
|
186
186
|
'job-id': '123',
|
|
187
187
|
'batch-size': 2,
|
|
188
188
|
}, mockConfig);
|
|
189
|
-
expect(utils_1.exitWithError).toHaveBeenCalledWith(`Destination argument value is not valid, please use the right format: ${colorette_1.yellow('<api-name@api-version>')}`);
|
|
189
|
+
expect(utils_1.exitWithError).toHaveBeenCalledWith(`Destination argument value is not valid, please use the right format: ${(0, colorette_1.yellow)('<api-name@api-version>')}`);
|
|
190
190
|
}));
|
|
191
191
|
it('push should work and encode name with spaces', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
192
192
|
const encodeURIComponentSpy = jest.spyOn(global, 'encodeURIComponent');
|
|
193
193
|
const mockConfig = Object.assign(Object.assign({}, config_1.ConfigFixture), { organization: 'test_org', apis: { 'my test api@v1': { root: 'path' } } });
|
|
194
|
-
yield push_1.handlePush({
|
|
194
|
+
yield (0, push_1.handlePush)({
|
|
195
195
|
upsert: true,
|
|
196
196
|
destination: 'my test api@v1',
|
|
197
197
|
branchName: 'test',
|
|
@@ -206,7 +206,7 @@ describe('push', () => {
|
|
|
206
206
|
describe('transformPush', () => {
|
|
207
207
|
it('should adapt the existing syntax', () => {
|
|
208
208
|
const cb = jest.fn();
|
|
209
|
-
push_1.transformPush(cb)({
|
|
209
|
+
(0, push_1.transformPush)(cb)({
|
|
210
210
|
api: 'openapi.yaml',
|
|
211
211
|
maybeDestination: '@testing_org/main@v1',
|
|
212
212
|
}, {});
|
|
@@ -217,7 +217,7 @@ describe('transformPush', () => {
|
|
|
217
217
|
});
|
|
218
218
|
it('should adapt the existing syntax (including branchName)', () => {
|
|
219
219
|
const cb = jest.fn();
|
|
220
|
-
push_1.transformPush(cb)({
|
|
220
|
+
(0, push_1.transformPush)(cb)({
|
|
221
221
|
api: 'openapi.yaml',
|
|
222
222
|
maybeDestination: '@testing_org/main@v1',
|
|
223
223
|
maybeBranchName: 'other',
|
|
@@ -230,7 +230,7 @@ describe('transformPush', () => {
|
|
|
230
230
|
});
|
|
231
231
|
it('should use --branch option firstly', () => {
|
|
232
232
|
const cb = jest.fn();
|
|
233
|
-
push_1.transformPush(cb)({
|
|
233
|
+
(0, push_1.transformPush)(cb)({
|
|
234
234
|
api: 'openapi.yaml',
|
|
235
235
|
maybeDestination: '@testing_org/main@v1',
|
|
236
236
|
maybeBranchName: 'other',
|
|
@@ -244,7 +244,7 @@ describe('transformPush', () => {
|
|
|
244
244
|
});
|
|
245
245
|
it('should work for a destination only', () => {
|
|
246
246
|
const cb = jest.fn();
|
|
247
|
-
push_1.transformPush(cb)({
|
|
247
|
+
(0, push_1.transformPush)(cb)({
|
|
248
248
|
api: '@testing_org/main@v1',
|
|
249
249
|
}, {});
|
|
250
250
|
expect(cb).toBeCalledWith({
|
|
@@ -253,7 +253,7 @@ describe('transformPush', () => {
|
|
|
253
253
|
});
|
|
254
254
|
it('should work for a api only', () => {
|
|
255
255
|
const cb = jest.fn();
|
|
256
|
-
push_1.transformPush(cb)({
|
|
256
|
+
(0, push_1.transformPush)(cb)({
|
|
257
257
|
api: 'test.yaml',
|
|
258
258
|
}, {});
|
|
259
259
|
expect(cb).toBeCalledWith({
|
|
@@ -262,7 +262,7 @@ describe('transformPush', () => {
|
|
|
262
262
|
});
|
|
263
263
|
it('should accept aliases for the old syntax', () => {
|
|
264
264
|
const cb = jest.fn();
|
|
265
|
-
push_1.transformPush(cb)({
|
|
265
|
+
(0, push_1.transformPush)(cb)({
|
|
266
266
|
api: 'alias',
|
|
267
267
|
maybeDestination: '@testing_org/main@v1',
|
|
268
268
|
}, {});
|
|
@@ -273,7 +273,7 @@ describe('transformPush', () => {
|
|
|
273
273
|
});
|
|
274
274
|
it('should use --job-id option firstly', () => {
|
|
275
275
|
const cb = jest.fn();
|
|
276
|
-
push_1.transformPush(cb)({
|
|
276
|
+
(0, push_1.transformPush)(cb)({
|
|
277
277
|
'batch-id': 'b-123',
|
|
278
278
|
'job-id': 'j-123',
|
|
279
279
|
api: 'test',
|
|
@@ -290,60 +290,60 @@ describe('transformPush', () => {
|
|
|
290
290
|
});
|
|
291
291
|
it('should accept no arguments at all', () => {
|
|
292
292
|
const cb = jest.fn();
|
|
293
|
-
push_1.transformPush(cb)({}, {});
|
|
293
|
+
(0, push_1.transformPush)(cb)({}, {});
|
|
294
294
|
expect(cb).toBeCalledWith({}, {});
|
|
295
295
|
});
|
|
296
296
|
});
|
|
297
297
|
describe('getDestinationProps', () => {
|
|
298
298
|
it('should get valid destination props for the full destination syntax', () => {
|
|
299
|
-
expect(push_1.getDestinationProps('@testing_org/main@v1', 'org-from-config')).toEqual({
|
|
299
|
+
expect((0, push_1.getDestinationProps)('@testing_org/main@v1', 'org-from-config')).toEqual({
|
|
300
300
|
organizationId: 'testing_org',
|
|
301
301
|
name: 'main',
|
|
302
302
|
version: 'v1',
|
|
303
303
|
});
|
|
304
304
|
});
|
|
305
305
|
it('should fallback the organizationId from a config for the short destination syntax', () => {
|
|
306
|
-
expect(push_1.getDestinationProps('main@v1', 'org-from-config')).toEqual({
|
|
306
|
+
expect((0, push_1.getDestinationProps)('main@v1', 'org-from-config')).toEqual({
|
|
307
307
|
organizationId: 'org-from-config',
|
|
308
308
|
name: 'main',
|
|
309
309
|
version: 'v1',
|
|
310
310
|
});
|
|
311
311
|
});
|
|
312
312
|
it('should fallback the organizationId from a config if no destination provided', () => {
|
|
313
|
-
expect(push_1.getDestinationProps(undefined, 'org-from-config')).toEqual({
|
|
313
|
+
expect((0, push_1.getDestinationProps)(undefined, 'org-from-config')).toEqual({
|
|
314
314
|
organizationId: 'org-from-config',
|
|
315
315
|
});
|
|
316
316
|
});
|
|
317
317
|
it('should return empty organizationId if there is no one found', () => {
|
|
318
|
-
expect(push_1.getDestinationProps('main@v1', undefined)).toEqual({
|
|
318
|
+
expect((0, push_1.getDestinationProps)('main@v1', undefined)).toEqual({
|
|
319
319
|
organizationId: undefined,
|
|
320
320
|
name: 'main',
|
|
321
321
|
version: 'v1',
|
|
322
322
|
});
|
|
323
323
|
});
|
|
324
324
|
it('should return organizationId from destination string', () => {
|
|
325
|
-
expect(push_1.getDestinationProps('@test-org/main@main-v1', undefined)).toEqual({
|
|
325
|
+
expect((0, push_1.getDestinationProps)('@test-org/main@main-v1', undefined)).toEqual({
|
|
326
326
|
organizationId: 'test-org',
|
|
327
327
|
name: 'main',
|
|
328
328
|
version: 'main-v1',
|
|
329
329
|
});
|
|
330
330
|
});
|
|
331
331
|
it('should return organizationId, version and empty name from destination string', () => {
|
|
332
|
-
expect(push_1.getDestinationProps('@test_org/@main_v1', undefined)).toEqual({
|
|
332
|
+
expect((0, push_1.getDestinationProps)('@test_org/@main_v1', undefined)).toEqual({
|
|
333
333
|
organizationId: 'test_org',
|
|
334
334
|
name: '',
|
|
335
335
|
version: 'main_v1',
|
|
336
336
|
});
|
|
337
337
|
});
|
|
338
338
|
it('should validate organizationId with space and version with dot', () => {
|
|
339
|
-
expect(push_1.getDestinationProps('@test org/simple_name@main.v1', undefined)).toEqual({
|
|
339
|
+
expect((0, push_1.getDestinationProps)('@test org/simple_name@main.v1', undefined)).toEqual({
|
|
340
340
|
organizationId: 'test org',
|
|
341
341
|
name: 'simple_name',
|
|
342
342
|
version: 'main.v1',
|
|
343
343
|
});
|
|
344
344
|
});
|
|
345
345
|
it('should not work with "@" in destination name', () => {
|
|
346
|
-
expect(push_1.getDestinationProps('@test org/simple@name@main.v1', undefined)).toEqual({
|
|
346
|
+
expect((0, push_1.getDestinationProps)('@test org/simple@name@main.v1', undefined)).toEqual({
|
|
347
347
|
organizationId: undefined,
|
|
348
348
|
name: undefined,
|
|
349
349
|
version: undefined,
|
|
@@ -362,9 +362,9 @@ describe('getApiRoot', () => {
|
|
|
362
362
|
},
|
|
363
363
|
};
|
|
364
364
|
it('should resolve the correct api for a valid name & version', () => {
|
|
365
|
-
expect(push_1.getApiRoot({ name: 'main', version: 'v1', config })).toEqual('openapi.yaml');
|
|
365
|
+
expect((0, push_1.getApiRoot)({ name: 'main', version: 'v1', config })).toEqual('openapi.yaml');
|
|
366
366
|
});
|
|
367
367
|
it('should resolve the latest version of api if there is no matching version', () => {
|
|
368
|
-
expect(push_1.getApiRoot({ name: 'main', version: 'latest', config })).toEqual('latest.yaml');
|
|
368
|
+
expect((0, push_1.getApiRoot)({ name: 'main', version: 'latest', config })).toEqual('latest.yaml');
|
|
369
369
|
});
|
|
370
370
|
});
|