persona-community-5/.pnpm-store/v3/files/6a/306ba2977284f58a49b402b92f52b6098087df8b504570acd649266aecbf1a17808bfa13590ba67210c5d7f066a9797e5d3f560c35b9d93f62d2cf2fb13a93
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

254 lines
4.9 KiB
Plaintext

import { outdent } from 'outdent';
import { validateDoc } from './utils';
it('should not report if summary field is valid', async () => {
const source = outdent`
openapi: 3.0.2
info:
title: Test
version: '1.0'
servers:
- url: http://google.com
paths:
'/ping':
summary: test
get:
responses:
'200':
description: example description
`;
expect(
await validateDoc(source, {
spec: 'error',
})
).toMatchInlineSnapshot(`[]`);
});
it('should report if summary field is not string ', async () => {
const source = outdent`
openapi: 3.0.2
info:
title: Test
version: '1.0'
servers:
- url: http://google.com
paths:
'/ping':
summary:
get:
responses:
'200':
description: example description
`;
expect(
await validateDoc(source, {
spec: 'error',
})
).toMatchInlineSnapshot(`
[
{
"location": "#/paths/~1ping/summary",
"message": "Expected type \`string\` but got \`null\`.",
},
]
`);
});
it('should not report if description field is valid', async () => {
const source = outdent`
openapi: 3.0.2
info:
title: Test
version: '1.0'
servers:
- url: http://google.com
paths:
'/ping':
description: test
get:
responses:
'200':
description: example description
`;
expect(
await validateDoc(source, {
spec: 'error',
})
).toMatchInlineSnapshot(`[]`);
});
it('should report if description field is not string', async () => {
const source = outdent`
openapi: 3.0.2
info:
title: Test
version: '1.0'
servers:
- url: http://google.com
paths:
'/ping':
description:
get:
responses:
'200':
description: example description
`;
expect(
await validateDoc(source, {
spec: 'error',
})
).toMatchInlineSnapshot(`
[
{
"location": "#/paths/~1ping/description",
"message": "Expected type \`string\` but got \`null\`.",
},
]
`);
});
it('should not report of a valid GET operation object', async () => {
const source = outdent`
openapi: 3.0.2
info:
title: Test
version: '1.0'
servers:
- url: http://google.com
paths:
'/ping':
get:
responses:
'200':
description: example description
`;
expect(
await validateDoc(source, {
spec: 'error',
})
).toMatchInlineSnapshot(`[]`);
});
it('should not report of a valid PUT operation object', async () => {
const source = outdent`
openapi: 3.0.2
info:
title: Test
version: '1.0'
servers:
- url: http://google.com
paths:
'/ping':
put:
tags:
- pet
summary: Update an existing pet
description: ''
operationId: updatePet
responses:
'400':
description: Invalid ID supplied
`;
expect(
await validateDoc(source, {
spec: 'error',
})
).toMatchInlineSnapshot(`[]`);
});
it('should not report of a valid Post operation object', async () => {
const source = outdent`
openapi: 3.0.2
info:
title: Test
version: '1.0'
servers:
- url: http://google.com
paths:
'/ping':
post:
tags:
- pet
summary: uploads an image
description: ''
operationId: uploadFile
parameters:
- name: petId
in: path
description: ID of pet to update
required: true
schema:
type: integer
format: int64
responses:
'200':
description: successful operation
`;
expect(
await validateDoc(source, {
spec: 'error',
})
).toMatchInlineSnapshot(`[]`);
});
it('should not report of a valid delete operation object', async () => {
const source = outdent`
openapi: 3.0.2
info:
title: Test
version: '1.0'
servers:
- url: http://google.com
paths:
'/ping':
delete:
tags:
- store
summary: Delete purchase order by ID
description: >-
For valid response try integer IDs with value < 1000. Anything above
1000 or nonintegers will generate API errors
operationId: deleteOrder
parameters:
- name: orderId
in: path
description: ID of the order that needs to be deleted
required: true
schema:
type: string
minimum: 1
responses:
'400':
description: Invalid ID supplied
`;
expect(
await validateDoc(source, {
spec: 'error',
})
).toMatchInlineSnapshot(`[]`);
});