-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.ts
46 lines (40 loc) · 1.65 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import path from 'node:path';
import { expect, assert } from 'chai';
import { mediaTypes as openAPI31MediaTypes } from '@swagger-api/apidom-parser-adapter-openapi-json-3-1';
import { mediaTypes as openAPI30MediaTypes } from '@swagger-api/apidom-parser-adapter-openapi-json-3-0';
import {
AnnotationElement,
ParseResultElement,
toJSON,
includesClasses,
} from '@swagger-api/apidom-core';
import convert from '../../../../../src';
describe('converter', function () {
context('strategies', function () {
context('openapi-3-1-to-openapi-3-0-3', function () {
context('license-identifier', function () {
const fixturePath = path.join(__dirname, 'fixtures', 'license-identifier.json');
let convertedParseResult: ParseResultElement;
beforeEach(async function () {
convertedParseResult = await convert(fixturePath, {
convert: {
sourceMediaType: openAPI31MediaTypes.findBy('3.1.0', 'json'),
targetMediaType: openAPI30MediaTypes.findBy('3.0.3', 'json'),
},
});
});
specify('should remove License.identifier field', async function () {
expect(toJSON(convertedParseResult.api!, undefined, 2)).toMatchSnapshot();
});
specify('should create WARNING annotation', async function () {
const annotations = Array.from(convertedParseResult.annotations);
const annotation = annotations.find((a: AnnotationElement) =>
a.code?.equals('license-identifier'),
);
assert.isDefined(annotation);
assert.isTrue(includesClasses(['warning'], annotation));
});
});
});
});
});