Skip to content

Commit df04f59

Browse files
committed
feat: Added tests
1 parent 5661ae0 commit df04f59

File tree

8 files changed

+152
-3
lines changed

8 files changed

+152
-3
lines changed

test/declarative-changes-in-rest-operation.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ describe('Number of declarative changes in rest operation test', () => {
3030
expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 }))
3131
})
3232

33+
test('Multiple use of one schema in another schema which is used in response pathItems', async () => {
34+
const result = await buildChangelogPackage('declarative-changes-in-rest-operation/case8')
35+
expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }))
36+
expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 }))
37+
})
38+
3339
test('Multiple use of one schema in both request and response (different severity)', async () => {
3440
const result = await buildChangelogPackage('declarative-changes-in-rest-operation/case3')
3541
expect(result).toEqual(changesSummaryMatcher({

test/merge/openapi/openapi.test.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,19 @@ describe('Merge openapi schemas', () => {
258258
})
259259

260260
test('Should throw on different methods content', async () => {
261-
// 1: [[../should-throw-on-different-methods/1.yaml]]
262-
// 2: [[../should-throw-on-different-methods/2.yaml]]
263-
const testId = 'should-throw-on-different-methods'
261+
// 1: [[../should-throw-on-different-methods/case1/1.yaml]]
262+
// 2: [[../should-throw-on-different-methods/case1/2.yaml]]
263+
const testId = 'should-throw-on-different-methods/case1'
264264
await expect(getTestData(testId)).rejects.toThrowError(/paths.\/path1/)
265265
})
266266

267+
test('Should throw on different pathItems methods content', async () => {
268+
// 1: [[../should-throw-on-different-methods/case2/1.yaml]]
269+
// 2: [[../should-throw-on-different-methods/case2/2.yaml]]
270+
const testId = 'should-throw-on-different-methods/case2'
271+
await expect(getTestData(testId)).rejects.toThrowError(/components.pathItems.path1/)
272+
})
273+
267274
test('Should merge with empty template', async () => {
268275
// 1: [[../should-merge-with-empty-template/1.yaml]]
269276
// 2: [[../should-merge-with-empty-template/2.yaml]]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
openapi: 3.1.0
2+
info:
3+
title: test
4+
version: 0.1.0
5+
paths:
6+
/path1:
7+
$ref: '#/components/pathItems/path1'
8+
components:
9+
pathItems:
10+
path1:
11+
post:
12+
parameters:
13+
- name: p1
14+
in: query
15+
schema:
16+
type: object
17+
responses:
18+
'200':
19+
description: OK
20+
content: { }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
openapi: 3.1.0
2+
info:
3+
title: test
4+
version: 0.1.0
5+
paths:
6+
/path1:
7+
$ref: '#/components/pathItems/path1'
8+
components:
9+
pathItems:
10+
path1:
11+
get:
12+
parameters:
13+
- name: p1
14+
in: query
15+
schema:
16+
type: object
17+
responses:
18+
'200':
19+
description: OK
20+
content: { }
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Sample API
4+
description: API specification example
5+
version: 1.0.0
6+
paths:
7+
/salesOrder:
8+
$ref: '#/components/pathItems/path1'
9+
components:
10+
pathItems:
11+
path1:
12+
get:
13+
operationId: getSalesOrder
14+
summary: get sales order
15+
responses:
16+
'200':
17+
description: OK
18+
content:
19+
application/json:
20+
schema:
21+
$ref: '#/components/schemas/SalesOrder'
22+
schemas:
23+
SalesOrder:
24+
title: SalesOrder
25+
type: object
26+
properties:
27+
id:
28+
type: string
29+
price:
30+
$ref: '#/components/schemas/SalesOrderPrice'
31+
SalesOrderPrice:
32+
title: SalesOrderPrice
33+
type: object
34+
properties:
35+
oneTimeDiscount:
36+
$ref: '#/components/schemas/MonetaryValue'
37+
oneTimeTotalWithTax:
38+
$ref: '#/components/schemas/MonetaryValue'
39+
oneTimeTotalWithTaxDiscounted:
40+
$ref: '#/components/schemas/MonetaryValue'
41+
MonetaryValue:
42+
title: MonetaryValue
43+
type: object
44+
properties:
45+
value:
46+
type: string #!
47+
currency:
48+
type: string
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Sample API
4+
description: API specification example
5+
version: 1.0.0
6+
paths:
7+
/salesOrder:
8+
$ref: '#/components/pathItems/path1'
9+
components:
10+
pathItems:
11+
path1:
12+
get:
13+
operationId: getSalesOrder
14+
summary: get sales order
15+
responses:
16+
'200':
17+
description: OK
18+
content:
19+
application/json:
20+
schema:
21+
$ref: '#/components/schemas/SalesOrder'
22+
schemas:
23+
SalesOrder:
24+
title: SalesOrder
25+
type: object
26+
properties:
27+
id:
28+
type: string
29+
price:
30+
$ref: '#/components/schemas/SalesOrderPrice'
31+
SalesOrderPrice:
32+
title: SalesOrderPrice
33+
type: object
34+
properties:
35+
oneTimeDiscount:
36+
$ref: '#/components/schemas/MonetaryValue'
37+
oneTimeTotalWithTax:
38+
$ref: '#/components/schemas/MonetaryValue'
39+
oneTimeTotalWithTaxDiscounted:
40+
$ref: '#/components/schemas/MonetaryValue'
41+
MonetaryValue:
42+
title: MonetaryValue
43+
type: object
44+
properties:
45+
value:
46+
type: number #!
47+
currency:
48+
type: string

0 commit comments

Comments
 (0)