Skip to content

Commit 644718a

Browse files
committed
Convert supplied examples to tests
1 parent 95f9298 commit 644718a

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

test/expected/one-less-server.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
openapi: 3.1.0
2+
info:
3+
title: API servers
4+
version: 1.0.0
5+
servers:
6+
- url: 'https://api.example.com'
7+
description: Production
8+
paths: {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
openapi: 3.1.0
2+
info:
3+
title: API servers
4+
version: 1.0.0
5+
servers:
6+
- url: 'https://api.dev.example.com'
7+
description: Dev
8+
- url: 'https://api.example.com'
9+
description: Production
10+
paths: {}

test/overlay.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ test('remove all description fields', () => {
5959
expect(result).toEqual(expectedOutput);
6060
});
6161

62+
test('remove a server array entry', () => {
63+
const openapiFile = "test/openapi/openapi-with-servers.yaml";
64+
const overlayFile = "test/overlays/remove-server.yaml";
65+
const expectedFile = "test/expected/one-less-server.yaml";
66+
const expectedOutput = fs.readFileSync(expectedFile, 'utf8');
67+
68+
const result = overlayFiles(openapiFile, overlayFile);
69+
70+
expect(result).toEqual(expectedOutput);
71+
});
72+
6273
test('fail to update a primitive string type', () => {
6374
const openapiFile = "test/openapi/immutable.yaml";
6475
const overlayFile = "test/overlays/immutable.yaml";

test/overlays/remove-server.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
overlay: 1.0.0
2+
info:
3+
title: Remove dev server
4+
version: 1.0.0
5+
extends: openapi-with-servers.yaml
6+
7+
actions:
8+
- target: $.servers[?( @.description == 'Dev' )]
9+
remove: true

0 commit comments

Comments
 (0)