|
1 |
| -// import { testRule, DiagnosticSeverity } from '../tester'; |
| 1 | +import { testRule, DiagnosticSeverity } from '../tester'; |
2 | 2 |
|
3 |
| -describe('asyncapi-document-unresolved', () => { |
4 |
| - it.todo('add tests after fixing https://github.com/asyncapi/spec-json-schemas/issues/296'); |
5 |
| -}); |
| 3 | +testRule('asyncapi-document-unresolved', [ |
| 4 | + { |
| 5 | + name: 'valid case', |
| 6 | + document: { |
| 7 | + asyncapi: '2.0.0', |
| 8 | + info: { |
| 9 | + title: 'Valid AsyncApi document', |
| 10 | + version: '1.0', |
| 11 | + }, |
| 12 | + channels: { |
| 13 | + someChannel: { |
| 14 | + publish: { |
| 15 | + message: { |
| 16 | + $ref: '#/components/messages/someMessage', |
| 17 | + }, |
| 18 | + }, |
| 19 | + }, |
| 20 | + }, |
| 21 | + components: { |
| 22 | + messages: { |
| 23 | + someMessage: {}, |
| 24 | + }, |
| 25 | + }, |
| 26 | + }, |
| 27 | + errors: [], |
| 28 | + }, |
6 | 29 |
|
7 |
| -// |
8 |
| -// testRule('asyncapi-document-unresolved', [ |
9 |
| -// { |
10 |
| -// name: 'valid case', |
11 |
| -// document: { |
12 |
| -// asyncapi: '2.0.0', |
13 |
| -// info: { |
14 |
| -// title: 'Valid AsyncApi document', |
15 |
| -// version: '1.0', |
16 |
| -// }, |
17 |
| -// channels: { |
18 |
| -// someChannel: { |
19 |
| -// publish: { |
20 |
| -// message: { |
21 |
| -// $ref: '#/components/messages/someMessage', |
22 |
| -// }, |
23 |
| -// }, |
24 |
| -// }, |
25 |
| -// }, |
26 |
| -// components: { |
27 |
| -// messages: { |
28 |
| -// someMessage: {}, |
29 |
| -// }, |
30 |
| -// }, |
31 |
| -// }, |
32 |
| -// errors: [], |
33 |
| -// }, |
| 30 | + { |
| 31 | + name: 'invalid case (reference for operation object is not allowed)', |
| 32 | + document: { |
| 33 | + asyncapi: '2.0.0', |
| 34 | + info: { |
| 35 | + title: 'Valid AsyncApi document', |
| 36 | + version: '1.0', |
| 37 | + }, |
| 38 | + channels: { |
| 39 | + someChannel: { |
| 40 | + publish: { |
| 41 | + $ref: '#/components/x-operations/someOperation', |
| 42 | + }, |
| 43 | + }, |
| 44 | + }, |
| 45 | + components: { |
| 46 | + 'x-operations': { |
| 47 | + someOperation: {}, |
| 48 | + }, |
| 49 | + }, |
| 50 | + }, |
| 51 | + errors: [ |
| 52 | + { |
| 53 | + message: 'Referencing in this place is not allowed', |
| 54 | + path: ['channels', 'someChannel', 'publish'], |
| 55 | + severity: DiagnosticSeverity.Error, |
| 56 | + }, |
| 57 | + ], |
| 58 | + }, |
34 | 59 |
|
35 |
| -// { |
36 |
| -// name: 'invalid case (reference for operation object is not allowed)', |
37 |
| -// document: { |
38 |
| -// asyncapi: '2.0.0', |
39 |
| -// info: { |
40 |
| -// title: 'Valid AsyncApi document', |
41 |
| -// version: '1.0', |
42 |
| -// }, |
43 |
| -// channels: { |
44 |
| -// someChannel: { |
45 |
| -// publish: { |
46 |
| -// $ref: '#/components/x-operations/someOperation', |
47 |
| -// }, |
48 |
| -// }, |
49 |
| -// }, |
50 |
| -// components: { |
51 |
| -// 'x-operations': { |
52 |
| -// someOperation: {}, |
53 |
| -// }, |
54 |
| -// }, |
55 |
| -// }, |
56 |
| -// errors: [ |
57 |
| -// { |
58 |
| -// message: 'Referencing in this place is not allowed', |
59 |
| -// path: ['channels', 'someChannel', 'publish'], |
60 |
| -// severity: DiagnosticSeverity.Error, |
61 |
| -// }, |
62 |
| -// ], |
63 |
| -// }, |
64 |
| - |
65 |
| -// { |
66 |
| -// name: 'invalid case (case when other errors should also occur but we filter them out - required info field is omitted)', |
67 |
| -// document: { |
68 |
| -// asyncapi: '2.0.0', |
69 |
| -// channels: { |
70 |
| -// someChannel: { |
71 |
| -// publish: { |
72 |
| -// $ref: '#/components/x-operations/someOperation', |
73 |
| -// }, |
74 |
| -// }, |
75 |
| -// }, |
76 |
| -// components: { |
77 |
| -// 'x-operations': { |
78 |
| -// someOperation: {}, |
79 |
| -// }, |
80 |
| -// }, |
81 |
| -// }, |
82 |
| -// errors: [ |
83 |
| -// { |
84 |
| -// message: 'Referencing in this place is not allowed', |
85 |
| -// path: ['channels', 'someChannel', 'publish'], |
86 |
| -// severity: DiagnosticSeverity.Error, |
87 |
| -// }, |
88 |
| -// ], |
89 |
| -// }, |
90 |
| -// ]); |
| 60 | + { |
| 61 | + name: 'invalid case (case when other errors should also occur but we filter them out - required info field is omitted)', |
| 62 | + document: { |
| 63 | + asyncapi: '2.0.0', |
| 64 | + channels: { |
| 65 | + someChannel: { |
| 66 | + publish: { |
| 67 | + $ref: '#/components/x-operations/someOperation', |
| 68 | + }, |
| 69 | + }, |
| 70 | + }, |
| 71 | + components: { |
| 72 | + 'x-operations': { |
| 73 | + someOperation: {}, |
| 74 | + }, |
| 75 | + }, |
| 76 | + }, |
| 77 | + errors: [ |
| 78 | + { |
| 79 | + message: 'Referencing in this place is not allowed', |
| 80 | + path: ['channels', 'someChannel', 'publish'], |
| 81 | + severity: DiagnosticSeverity.Error, |
| 82 | + }, |
| 83 | + ], |
| 84 | + }, |
| 85 | +]); |
0 commit comments