@@ -4,7 +4,36 @@ import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../
44import { BaseResolver } from '../../../resolve' ;
55
66describe ( 'Arazzo spot-supported-versions' , ( ) => {
7- const document = parseYamlToDocument (
7+ const documentWithUnsupportedVersion = parseYamlToDocument (
8+ outdent `
9+ arazzo: '1.0.2'
10+ info:
11+ title: Cool API
12+ version: 1.0.0
13+ description: A cool API
14+ sourceDescriptions:
15+ - name: museum-api
16+ type: openapi
17+ url: openapi.yaml
18+ workflows:
19+ - workflowId: get-museum-hours
20+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
21+ parameters:
22+ - in: header
23+ name: Authorization
24+ value: Basic Og==
25+ steps:
26+ - stepId: get-museum-hours
27+ description: >-
28+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
29+ operationId: museum-api.getMuseumHours
30+ successCriteria:
31+ - condition: $statusCode == 200
32+ ` ,
33+ 'arazzo.yaml'
34+ ) ;
35+
36+ const documentWithSupportedVersion = parseYamlToDocument (
837 outdent `
938 arazzo: '1.0.1'
1039 info:
@@ -36,7 +65,7 @@ describe('Arazzo spot-supported-versions', () => {
3665 it ( 'should report on arazzo version error' , async ( ) => {
3766 const results = await lintDocument ( {
3867 externalRefResolver : new BaseResolver ( ) ,
39- document,
68+ document : documentWithUnsupportedVersion ,
4069 config : await makeConfig ( {
4170 rules : { 'spot-supported-versions' : 'error' } ,
4271 } ) ,
@@ -52,7 +81,7 @@ describe('Arazzo spot-supported-versions', () => {
5281 "source": "arazzo.yaml",
5382 },
5483 ],
55- "message": "Only 1.0.0 Arazzo version is supported by Spot.",
84+ "message": "Only 1.0.0, 1.0.1 Arazzo versions are supported by Spot.",
5685 "ruleId": "spot-supported-versions",
5786 "severity": "error",
5887 "suggest": [],
@@ -61,10 +90,22 @@ describe('Arazzo spot-supported-versions', () => {
6190 ` ) ;
6291 } ) ;
6392
64- it ( 'should not report on arazzo version error' , async ( ) => {
93+ it ( 'should not report on arazzo version error when supported version is used' , async ( ) => {
94+ const results = await lintDocument ( {
95+ externalRefResolver : new BaseResolver ( ) ,
96+ document : documentWithSupportedVersion ,
97+ config : await makeConfig ( {
98+ rules : { 'spot-supported-versions' : 'error' } ,
99+ } ) ,
100+ } ) ;
101+
102+ expect ( replaceSourceWithRef ( results ) ) . toMatchInlineSnapshot ( `[]` ) ;
103+ } ) ;
104+
105+ it ( 'should not report on arazzo version error when rule is not configured' , async ( ) => {
65106 const results = await lintDocument ( {
66107 externalRefResolver : new BaseResolver ( ) ,
67- document,
108+ document : documentWithSupportedVersion ,
68109 config : await makeConfig ( {
69110 rules : { } ,
70111 } ) ,
0 commit comments