persona-community-5/.pnpm-store/v3/files/e5/09a4d85843a19308f988e4798c17329a3c9b12d7d9c14d69874e353235e632e44fb2b3389f2e7a967fcf35a011daecf4c1b09a45b3f021280dc26f6875217d
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

101 lines
2.2 KiB
Plaintext

import { Assertions } from '../.';
const opts = {
'0': {
subject: {
type: 'Operation',
property: 'summary',
},
description: 'example warn text',
severity: 'warn',
assertions: { pattern: '/example/' },
},
'1': {
subject: {
type: 'PathItem',
},
where: [
{
subject: { type: 'Operation', filterInParentKeys: ['post'], property: 'responses' },
assertions: { defined: true },
},
],
description: 'example warn text',
severity: 'warn',
assertions: { mutuallyExclusive: ['summary', 'security'] },
},
'2': {
subject: { type: 'PathItem', property: 'tags' },
where: [
{ subject: { type: 'Operation', property: 'responses' }, assertions: { defined: true } },
],
description: 'example warn text',
severity: 'warn',
assertions: { sortOrder: 'desc' },
},
'3': {
subject: { type: 'Foo', property: 'test' },
where: [
{ subject: { type: 'Bar' }, assertions: {} },
{ subject: { type: 'Baz' }, assertions: {} },
],
description: 'example warn text',
severity: 'warn',
assertions: { sortOrder: 'desc' },
},
'4': {
subject: {
type: 'any',
property: 'description',
},
description: 'example warn text',
severity: 'warn',
assertions: { notPattern: '/example/' },
},
};
describe('Oas3 assertions', () => {
it('should return the right visitor structure', () => {
const visitors = Assertions(opts as any);
expect(visitors).toMatchInlineSnapshot(`
[
{
"Operation": {
"enter": [Function],
},
},
{
"Operation": {
"PathItem": {
"enter": [Function],
},
"skip": [Function],
},
},
{
"Operation": {
"PathItem": {
"enter": [Function],
},
"skip": [Function],
},
},
{
"Bar": {
"Baz": {
"Foo": {
"enter": [Function],
},
},
},
},
{
"any": {
"enter": [Function],
},
},
]
`);
});
});