persona-community-5/.pnpm-store/v3/files/c6/bc2abdf6af3ee8710d116b5c6913f9c7fa95835cbab21aae65a384c2c1252abec375a2ce84591f5e7a421abf55f9a3d2ab8012d4eb312bd7e6237cadabb928
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

80 lines
2.3 KiB
Plaintext

import { outdent } from 'outdent';
import { lintDocument } from '../../../lint';
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
import { BaseResolver } from '../../../resolve';
describe('Oas3 oas3-no-server-trailing-slash', () => {
it('oas3-no-server-trailing-slash: should report on server object with trailing slash', async () => {
const document = parseYamlToDocument(
outdent`
openapi: 3.0.0
servers:
- url: https://somedomain.com/
`,
'foobar.yaml'
);
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
config: await makeConfig({ rules: { 'no-server-trailing-slash': 'error' } }),
});
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
[
{
"location": [
{
"pointer": "#/servers/0/url",
"reportOnKey": false,
"source": "foobar.yaml",
},
],
"message": "Server \`url\` should not have a trailing slash.",
"ruleId": "no-server-trailing-slash",
"severity": "error",
"suggest": [],
},
]
`);
});
it('oas3-no-server-trailing-slash: should not report on server object with no trailing slash', async () => {
const document = parseYamlToDocument(
outdent`
openapi: 3.0.0
servers:
- url: https://somedomain.com
`,
'foobar.yaml'
);
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
config: await makeConfig({ rules: { 'no-server-trailing-slash': 'error' } }),
});
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
});
it('oas3-no-server-trailing-slash: should not report on server object with no trailing slash if the url is root', async () => {
const document = parseYamlToDocument(
outdent`
openapi: 3.0.0
servers:
- url: /
`,
'foobar.yaml'
);
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
config: await makeConfig({ rules: { 'no-server-trailing-slash': 'error' } }),
});
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
});
});