| 
 | 1 | +import { compareFiles } from '../utils'  | 
 | 2 | +import { diffsMatcher } from '../../helper/matchers'  | 
 | 3 | +import { breaking, DiffAction, nonBreaking } from '../../../src'  | 
 | 4 | + | 
 | 5 | +const SUITE_ID = 'pathItems'  | 
 | 6 | + | 
 | 7 | +const PATH_ITEM_PATH = [  | 
 | 8 | +  'components',  | 
 | 9 | +  'pathItems',  | 
 | 10 | +  'UserOps',  | 
 | 11 | +]  | 
 | 12 | + | 
 | 13 | +describe('Openapi3.1 PathItems', () => {  | 
 | 14 | + | 
 | 15 | +  test('Add method in path item', async () => {  | 
 | 16 | +    const testId = 'add-method-in-pathitem'  | 
 | 17 | +    const result = await compareFiles(SUITE_ID, testId)  | 
 | 18 | +    expect(result).toEqual(diffsMatcher([  | 
 | 19 | +      expect.objectContaining({  | 
 | 20 | +        action: DiffAction.add,  | 
 | 21 | +        afterDeclarationPaths: [[...PATH_ITEM_PATH, 'post']],  | 
 | 22 | +        type: nonBreaking,  | 
 | 23 | +      }),  | 
 | 24 | +    ]))  | 
 | 25 | +  })  | 
 | 26 | + | 
 | 27 | +  test('Add unused method in path item', async () => {  | 
 | 28 | +    const testId = 'add-unused-method-in-pathitem'  | 
 | 29 | +    const result = await compareFiles(SUITE_ID, testId)  | 
 | 30 | +    expect(result).toEqual([])  | 
 | 31 | +  })  | 
 | 32 | + | 
 | 33 | +  test('Remove method in path item', async () => {  | 
 | 34 | +    const testId = 'remove-method-in-pathitem'  | 
 | 35 | +    const result = await compareFiles(SUITE_ID, testId)  | 
 | 36 | +    expect(result).toEqual(diffsMatcher([  | 
 | 37 | +      expect.objectContaining({  | 
 | 38 | +        action: DiffAction.remove,  | 
 | 39 | +        beforeDeclarationPaths: [[...PATH_ITEM_PATH, 'post']],  | 
 | 40 | +        type: breaking,  | 
 | 41 | +      }),  | 
 | 42 | +    ]))  | 
 | 43 | +  })  | 
 | 44 | + | 
 | 45 | +  test('Replace inline path item to ref', async () => {  | 
 | 46 | +    const testId = 'replace-inline-pathitem-to-ref'  | 
 | 47 | +    const result = await compareFiles(SUITE_ID, testId)  | 
 | 48 | +    expect(result).toEqual([])  | 
 | 49 | +  })  | 
 | 50 | + | 
 | 51 | +  test('Replace ref path item to inline', async () => {  | 
 | 52 | +    const testId = 'replace-ref-pathitem-to-inline'  | 
 | 53 | +    const result = await compareFiles(SUITE_ID, testId)  | 
 | 54 | +    expect(result).toEqual([])  | 
 | 55 | +  })  | 
 | 56 | +})  | 
0 commit comments