Skip to content

Commit 213fa2a

Browse files
committed
chore: improve JSDoc for splitReqAndRes and processFileContent with detailed parameter and operation descriptions (#3886)
Signed-off-by: Michał Walczak <[email protected]>
1 parent db1d6f4 commit 213fa2a

File tree

1 file changed

+25
-14
lines changed
  • packages/server/tests/acceptance/data/conformity/utils

1 file changed

+25
-14
lines changed

packages/server/tests/acceptance/data/conformity/utils/processors.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import { updateRequestParams } from './overwrites';
66
import { sendRequestToRelay } from './utils';
77
import { checkResponseFormat, findSchema, isResponseValid } from './validations';
88

9+
/**
10+
* Splits a given input string into distinct segments representing the request, the response, and optional wildcard fields.
11+
*
12+
* @param {string} content - The input string to be segmented.
13+
* @returns {{ request: string, response: string, wildcards: string[] }} - An object containing the separated request, response strings, and wildcard fields.
14+
*/
915
export function splitReqAndRes(content: string) {
10-
/**
11-
* Splits a given input string into distinct segments representing the request, the response, and optional wildcard fields.
12-
*
13-
* @param {string} content - The input string to be segmented.
14-
* @returns {{ request: string, response: string, wildcards: string[] }} - An object containing the separated request, response strings, and wildcard fields.
15-
*/
1616
const lines = content
1717
.split('\n')
1818
.map((line: string) => line.trim())
@@ -44,15 +44,26 @@ export function splitReqAndRes(content: string) {
4444
};
4545
}
4646

47+
/**
48+
* Processes file content for API testing by executing requests against a relay server
49+
* and validating the responses according to various validation strategies.
50+
*
51+
* @param {string} relayUrl - The URL of the relay server to send requests to
52+
* @param {string} directory - The directory path used for schema lookup
53+
* @param {string} file - The name of the file being processed (used for logging)
54+
* @param {FileContent} content - The file content object containing request, response, and wildcards
55+
* @returns {Promise<void>} A promise that resolves when processing is complete
56+
*
57+
* @description
58+
* This function performs the following operations:
59+
* 1. Updates request parameters based on the file context
60+
* 2. Sends the modified request to the relay server
61+
* 3. Validates the response using one of three strategies:
62+
* - Error response validation (expects validation to fail)
63+
* - Schema validation (when schema exists and no wildcards)
64+
* - Response format validation (key-by-key comparison with wildcards support)
65+
*/
4766
export async function processFileContent(relayUrl: string, directory: string, file: string, content: FileContent) {
48-
/**
49-
* Processes a file from the execution apis repo
50-
* containing test request and response data.
51-
*
52-
* @param {string} file - The name of the file being processed.
53-
* @param {Object} content - The content of the file, consisting of request and response data.
54-
* @returns {Array<string>} - An array of missing keys in the response data.
55-
*/
5667
console.log('Executing for ', file);
5768
console.log('Original request:', content.request);
5869
const modifiedRequest = await updateRequestParams(file, JSON.parse(content.request));

0 commit comments

Comments
 (0)