persona-community-5/.pnpm-store/v3/files/25/6ea74f64475dedcb1591e0bbcd5c3413c936877c7a1d0bfe65770ad8becef03940271a06e0538ca3076f1a543093800549e4ad4916c41a214059bb7184a875
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

66 lines
2.0 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-example-value-and-externalValue', () => {
it('oas3-no-example-value-and-externalValue: should report on example object with both value and external value', async () => {
const document = parseYamlToDocument(
outdent`
openapi: 3.0.0
components:
examples:
some:
value: 12
externalValue: https://1.1.1.1
`,
'foobar.yaml'
);
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
config: await makeConfig({ rules: { 'no-example-value-and-externalValue': 'error' } }),
});
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
[
{
"location": [
{
"pointer": "#/components/examples/some/value",
"reportOnKey": true,
"source": "foobar.yaml",
},
],
"message": "Example object can have either \`value\` or \`externalValue\` fields.",
"ruleId": "no-example-value-and-externalValue",
"severity": "error",
"suggest": [],
},
]
`);
});
it('oas3-no-example-value-and-externalValue: should not report on example object with value OR external value', async () => {
const document = parseYamlToDocument(
outdent`
openapi: 3.0.0
components:
examples:
some:
value: 12
`,
'foobar.yaml'
);
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
config: await makeConfig({ rules: { 'no-example-value-and-externalValue': 'error' } }),
});
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
});
});