Skip to content

Commit 2daac75

Browse files
committed
fix: add additional cases for complex extensions
1 parent 5ebdf53 commit 2daac75

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

test/openapi.specificationExtensions.test.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,45 @@ describe('OpenAPI specification extensions changes classification', () => {
370370
]))
371371
})
372372

373-
it(`change complex value of specification extension`, () => {
374-
const { before, after } = prepareSpecsForComparison(fullExtensionPath, { nested: 'original' }, { nested: 'modified' })
373+
it(`add property to complex value of specification extension`, () => {
374+
const { before, after } = prepareSpecsForComparison(fullExtensionPath, { nested: {} }, { nested: {property: 'value'} })
375+
376+
const { diffs } = apiDiff(before, after, OPTIONS)
377+
378+
expect(diffs).toEqual(diffsMatcher([
379+
expect.objectContaining({
380+
afterDeclarationPaths: [[...fullExtensionPath, 'nested', 'property']],
381+
action: DiffAction.add,
382+
type: expectedType,
383+
afterValue: 'value',
384+
})
385+
]))
386+
})
387+
388+
it(`delete property from complex value of specification extension`, () => {
389+
const { before, after } = prepareSpecsForComparison(fullExtensionPath, { nested: {property: 'value'} }, { nested: {} })
390+
391+
const { diffs } = apiDiff(before, after, OPTIONS)
392+
393+
expect(diffs).toEqual(diffsMatcher([
394+
expect.objectContaining({
395+
beforeDeclarationPaths: [[...fullExtensionPath, 'nested', 'property']],
396+
action: DiffAction.remove,
397+
type: expectedType,
398+
beforeValue: 'value',
399+
})
400+
]))
401+
})
402+
403+
it(`change property in complex value of specification extension`, () => {
404+
const { before, after } = prepareSpecsForComparison(fullExtensionPath, { nested: {property: 'original'} }, { nested: {property: 'modified'} })
375405

376406
const { diffs } = apiDiff(before, after, OPTIONS)
377407

378408
expect(diffs).toEqual(diffsMatcher([
379409
expect.objectContaining({
380-
beforeDeclarationPaths: [[...fullExtensionPath, 'nested']],
381-
afterDeclarationPaths: [[...fullExtensionPath, 'nested']],
410+
beforeDeclarationPaths: [[...fullExtensionPath, 'nested', 'property']],
411+
afterDeclarationPaths: [[...fullExtensionPath, 'nested', 'property']],
382412
action: DiffAction.replace,
383413
type: expectedType,
384414
beforeValue: 'original',

0 commit comments

Comments
 (0)