Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion tests/src/client/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import { parseCLI } from '../utils';
import { parseCLI, checkIfLanguageExists } from '../utils';

import { generateTests } from './generate';

async function main(): Promise<void> {
const { lang, client } = parseCLI(process.argv, 'generate:client');

if (!checkIfLanguageExists(lang)) {
// eslint-disable-next-line no-console
console.log(
`Skipping CTS generation > generate:client for ${lang}-${client}: Language not present in the config.json file`
);

return;
}

// eslint-disable-next-line no-console
console.log(`Generating CTS > generate:client for ${lang}-${client}`);

Expand Down
12 changes: 11 additions & 1 deletion tests/src/methods/requests/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import { parseCLI } from '../../utils';
import { parseCLI, checkIfLanguageExists } from '../../utils';

import { generateTests } from './generate';

async function main(): Promise<void> {
const { lang, client } = parseCLI(process.argv, 'generate:methods:requests');

if (!checkIfLanguageExists(lang)) {
// eslint-disable-next-line no-console
console.log(
`Skipping CTS generation > generate:methods:requests for ${lang}-${client}: Language not present in the config.json file`
);

return;
}

// eslint-disable-next-line no-console
console.log(
`Generating CTS > generate:methods:requests for ${lang}-${client}`
Expand Down
11 changes: 11 additions & 0 deletions tests/src/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
capitalize,
checkIfLanguageExists,
createClientName,
removeEnumType,
removeObjectName,
Expand Down Expand Up @@ -103,4 +104,14 @@ describe('utils', () => {
});
});
});

describe('checkIfLanguageExists', () => {
it('returns `true` if the language is present in the config', () => {
expect(checkIfLanguageExists('javascript')).toBe(true);
});

it('returns `false` if the language is not present in the config', () => {
expect(checkIfLanguageExists('algo')).toBe(false);
});
});
});
4 changes: 4 additions & 0 deletions tests/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ export function removeObjectName(obj: any): any {
return obj;
}

export function checkIfLanguageExists(language: string): boolean {
return Boolean(ctsConfig[language]);
}

export function removeEnumType(obj: any): any {
if (typeof obj === 'object') {
if (Array.isArray(obj)) {
Expand Down