Skip to content

Commit

Permalink
chore: prettier fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryAnansky committed Feb 18, 2025
1 parent 344de08 commit d4cf1e2
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { resolveReusableComponentItem } from '../../config-parser';

describe('resolveReusableComponentItem', () => {
it('should return parameter if not reference', () => {
expect(resolveReusableComponentItem({ in: 'query', name: 'test', value: 'test' }, {} as any)).toEqual({
expect(
resolveReusableComponentItem({ in: 'query', name: 'test', value: 'test' }, {} as any)
).toEqual({
in: 'query',
name: 'test',
value: 'test',
Expand All @@ -31,7 +33,9 @@ describe('resolveReusableComponentItem', () => {
});

it('should throw an error if reference is not found', () => {
expect(() => resolveReusableComponentItem({ reference: '$components.some.page' }, {} as any)).toThrow(
expect(() =>
resolveReusableComponentItem({ reference: '$components.some.page' }, {} as any)
).toThrow(
'Invalid reference: available components are $components.parameters, $components.failureActions, or $components.successActions'
);
});
Expand Down
222 changes: 117 additions & 105 deletions packages/respect-core/src/modules/__tests__/flow-runner/run-step.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1132,24 +1132,26 @@ describe('runStep', () => {
const parentWorkflowId = undefined;
const parentStepId = undefined;

(callAPIAndAnalyzeResults as jest.Mock).mockImplementationOnce(async ({ step }: { step: Step }) => {
step.checks = [
{
name: CHECKS.STATUS_CODE_CHECK,
pass: true,
message: '',
severity: 'error',
},
{
name: 'MIME-TYPE CHECK',
pass: true,
message: '',
severity: 'error',
},
];
(callAPIAndAnalyzeResults as jest.Mock).mockImplementationOnce(
async ({ step }: { step: Step }) => {
step.checks = [
{
name: CHECKS.STATUS_CODE_CHECK,
pass: true,
message: '',
severity: 'error',
},
{
name: 'MIME-TYPE CHECK',
pass: true,
message: '',
severity: 'error',
},
];

return { successCriteriaCheck: true, expectCheck: true };
});
return { successCriteriaCheck: true, expectCheck: true };
}
);

(checkCriteria as jest.Mock).mockImplementation(() => [
{
Expand Down Expand Up @@ -1253,24 +1255,26 @@ describe('runStep', () => {
const parentStepId = undefined;

// @ts-ignore
(callAPIAndAnalyzeResults as jest.Mock).mockImplementationOnce(async ({ step }: { step: Step }) => {
step.checks = [
{
name: CHECKS.STATUS_CODE_CHECK,
pass: false,
message: '',
severity: 'error',
},
{
name: CHECKS.CONTENT_TYPE_CHECK,
pass: false,
message: '',
severity: 'error',
},
];
(callAPIAndAnalyzeResults as jest.Mock).mockImplementationOnce(
async ({ step }: { step: Step }) => {
step.checks = [
{
name: CHECKS.STATUS_CODE_CHECK,
pass: false,
message: '',
severity: 'error',
},
{
name: CHECKS.CONTENT_TYPE_CHECK,
pass: false,
message: '',
severity: 'error',
},
];

return { successCriteriaCheck: false, expectCheck: true };
});
return { successCriteriaCheck: false, expectCheck: true };
}
);

(checkCriteria as jest.Mock).mockImplementation(() => [
{
Expand Down Expand Up @@ -1364,24 +1368,26 @@ describe('runStep', () => {
const parentStepId = undefined;

// @ts-ignore
(callAPIAndAnalyzeResults as jest.Mock).mockImplementationOnce(async ({ step }: { step: Step }) => {
step.checks = [
{
name: CHECKS.STATUS_CODE_CHECK,
pass: false,
message: '',
severity: 'error',
},
{
name: CHECKS.CONTENT_TYPE_CHECK,
pass: false,
message: '',
severity: 'error',
},
];
(callAPIAndAnalyzeResults as jest.Mock).mockImplementationOnce(
async ({ step }: { step: Step }) => {
step.checks = [
{
name: CHECKS.STATUS_CODE_CHECK,
pass: false,
message: '',
severity: 'error',
},
{
name: CHECKS.CONTENT_TYPE_CHECK,
pass: false,
message: '',
severity: 'error',
},
];

return { successCriteriaCheck: false, expectCheck: true };
});
return { successCriteriaCheck: false, expectCheck: true };
}
);

(checkCriteria as jest.Mock).mockImplementation(() => [
{
Expand Down Expand Up @@ -1868,68 +1874,74 @@ describe('runStep', () => {
const parentStepId = undefined;

// @ts-ignore
(callAPIAndAnalyzeResults as jest.Mock).mockImplementationOnce(async ({ step }: { step: Step }) => {
step.checks = [
{
name: CHECKS.STATUS_CODE_CHECK,
pass: false,
message: '',
severity: 'error',
},
];

if (step.stepId === 'get-bird') {
step.response = {
body: {
bird: '🐦',
name: 'hawk',
(callAPIAndAnalyzeResults as jest.Mock).mockImplementationOnce(
async ({ step }: { step: Step }) => {
step.checks = [
{
name: CHECKS.STATUS_CODE_CHECK,
pass: false,
message: '',
severity: 'error',
},
statusCode: 200,
headers: new Headers(),
contentType: 'application/json',
} as unknown as ResponseContext;
}
];

return { successCriteriaCheck: false, expectCheck: true };
});
if (step.stepId === 'get-bird') {
step.response = {
body: {
bird: '🐦',
name: 'hawk',
},
statusCode: 200,
headers: new Headers(),
contentType: 'application/json',
} as unknown as ResponseContext;
}

(callAPIAndAnalyzeResults as jest.Mock).mockImplementationOnce(async ({ step }: { step: Step }) => {
step.checks = [
{
name: CHECKS.STATUS_CODE_CHECK,
pass: true,
message: '',
severity: 'error',
},
];
return { successCriteriaCheck: false, expectCheck: true };
}
);

return { successCriteriaCheck: true, expectCheck: true };
});
(callAPIAndAnalyzeResults as jest.Mock).mockImplementationOnce(
async ({ step }: { step: Step }) => {
step.checks = [
{
name: CHECKS.STATUS_CODE_CHECK,
pass: true,
message: '',
severity: 'error',
},
];

(callAPIAndAnalyzeResults as jest.Mock).mockImplementationOnce(async ({ step }: { step: Step }) => {
step.checks = [
{
name: CHECKS.STATUS_CODE_CHECK,
pass: true,
message: '',
severity: 'error',
},
];
return { successCriteriaCheck: true, expectCheck: true };
}
);

if (step.stepId === 'get-bird') {
step.response = {
body: {
bird: '🐦',
name: 'hawk',
(callAPIAndAnalyzeResults as jest.Mock).mockImplementationOnce(
async ({ step }: { step: Step }) => {
step.checks = [
{
name: CHECKS.STATUS_CODE_CHECK,
pass: true,
message: '',
severity: 'error',
},
statusCode: 200,
headers: new Headers(),
contentType: 'application/json',
} as unknown as ResponseContext;
}
];

return { successCriteriaCheck: true, expectCheck: true };
});
if (step.stepId === 'get-bird') {
step.response = {
body: {
bird: '🐦',
name: 'hawk',
},
statusCode: 200,
headers: new Headers(),
contentType: 'application/json',
} as unknown as ResponseContext;
}

return { successCriteriaCheck: true, expectCheck: true };
}
);

(checkCriteria as jest.Mock).mockImplementation(() => [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,13 @@ describe('runTestFile', () => {
(readYaml as jest.Mock).mockResolvedValue(mockDocument.parsed);

await expect(
runTestFile({
file: 'test.yaml',
testDescription,
}, {})
runTestFile(
{
file: 'test.yaml',
testDescription,
},
{}
)
).rejects.toMatchSnapshot();
});

Expand Down Expand Up @@ -203,9 +206,12 @@ describe('runTestFile', () => {
},
});

await runTestFile({
file: 'test.yaml',
}, {});
await runTestFile(
{
file: 'test.yaml',
},
{}
);

expect(runStep).toHaveBeenCalledTimes(1);
});
Expand Down Expand Up @@ -293,9 +299,12 @@ describe('runTestFile', () => {
},
});

await runTestFile({
file: 'test.yaml',
}, {});
await runTestFile(
{
file: 'test.yaml',
},
{}
);

// called 3 times, one for each step from each workflow and one from dependsOn
expect(runStep).toHaveBeenCalledTimes(3);
Expand Down Expand Up @@ -480,9 +489,12 @@ describe('runTestFile', () => {
});

await expect(
runTestFile({
file: 'test.yaml',
}, {})
runTestFile(
{
file: 'test.yaml',
},
{}
)
).rejects.toThrowError('Dependent workflows has failed steps');
}, 8000);

Expand Down
1 change: 0 additions & 1 deletion packages/respect-core/src/modules/checks/severity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { formatCliInputs } from '../flow-runner';
import type { CHECKS } from './checks';
import type { RuleSeverity } from '@redocly/openapi-core/lib/config/types';


export const DEFAULT_SEVERITY_CONFIGURATION: {
[key in keyof typeof CHECKS]: RuleSeverity;
} = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { DefaultLogger } from '../../utils/logger/logger';

import type { RuntimeExpressionContext, TestContext, Workflow } from '../../types';


const logger = DefaultLogger.getInstance();

export interface ParsedParameters {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { resolveReusableObjectReference } from './resolve-reusable-object-refere

import type { OnFailureObject, OnSuccessObject, Parameter, TestContext } from '../../types';


export function resolveReusableComponentItem<
T extends OnSuccessObject | OnFailureObject | Parameter
>(item: T, ctx: TestContext): T {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {
Parameter,
} from '../../types';


type ComponentType<T extends ReusableObject> =
T['reference'] extends `$components.successActions${string}`
? OnSuccessObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type { Parameter } from '../../types';
import type { ParameterWithIn } from '../config-parser';
import type { OperationDetails } from './get-operation-from-description';


export interface OpenApiRequestData {
requestBody?: Record<string, unknown>;
contentType?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { resolveInputValuesToSchema } from '../inputs';
import { getPublicSteps } from './set-public-steps';

Expand Down
Loading

0 comments on commit d4cf1e2

Please sign in to comment.