|
| 1 | +import { describe, expect, it } from 'vitest' |
| 2 | +import { parsePropertiesContent } from './generate-docs' |
| 3 | + |
| 4 | +describe('documentation output-property parsing', () => { |
| 5 | + it('retains representative non-NetSuite response properties named items', () => { |
| 6 | + const googleFormsProperties = parsePropertiesContent(` |
| 7 | + formId: { |
| 8 | + type: 'string', |
| 9 | + description: 'The form identifier', |
| 10 | + }, |
| 11 | + items: { |
| 12 | + type: 'array', |
| 13 | + description: 'The form items', |
| 14 | + items: { |
| 15 | + type: 'object', |
| 16 | + properties: { |
| 17 | + itemId: { |
| 18 | + type: 'string', |
| 19 | + description: 'The item identifier', |
| 20 | + }, |
| 21 | + }, |
| 22 | + }, |
| 23 | + }, |
| 24 | + `) |
| 25 | + const onePasswordProperties = parsePropertiesContent(` |
| 26 | + id: { |
| 27 | + type: 'string', |
| 28 | + description: 'The vault identifier', |
| 29 | + }, |
| 30 | + items: { |
| 31 | + type: 'number', |
| 32 | + description: 'The number of items in the vault', |
| 33 | + }, |
| 34 | + `) |
| 35 | + |
| 36 | + expect(googleFormsProperties.items).toMatchObject({ |
| 37 | + type: 'array', |
| 38 | + description: 'The form items', |
| 39 | + items: { |
| 40 | + type: 'object', |
| 41 | + properties: { |
| 42 | + itemId: { |
| 43 | + type: 'string', |
| 44 | + description: 'The item identifier', |
| 45 | + }, |
| 46 | + }, |
| 47 | + }, |
| 48 | + }) |
| 49 | + expect(onePasswordProperties.items).toEqual({ |
| 50 | + type: 'number', |
| 51 | + description: 'The number of items in the vault', |
| 52 | + }) |
| 53 | + }) |
| 54 | + |
| 55 | + it('does not promote nested array-schema items to response properties', () => { |
| 56 | + const gongProperties = parsePropertiesContent(` |
| 57 | + outline: { |
| 58 | + type: 'array', |
| 59 | + description: 'The call outline', |
| 60 | + items: { |
| 61 | + type: 'object', |
| 62 | + properties: { |
| 63 | + section: { |
| 64 | + type: 'string', |
| 65 | + description: 'The outline section', |
| 66 | + }, |
| 67 | + items: { |
| 68 | + type: 'array', |
| 69 | + description: 'The section items', |
| 70 | + items: { |
| 71 | + type: 'string', |
| 72 | + description: 'An outline item', |
| 73 | + }, |
| 74 | + }, |
| 75 | + }, |
| 76 | + }, |
| 77 | + }, |
| 78 | + `) |
| 79 | + |
| 80 | + expect(Object.keys(gongProperties)).toEqual(['outline']) |
| 81 | + expect(gongProperties.outline.items.properties.items).toMatchObject({ |
| 82 | + type: 'array', |
| 83 | + description: 'The section items', |
| 84 | + items: { |
| 85 | + type: 'string', |
| 86 | + description: 'An outline item', |
| 87 | + }, |
| 88 | + }) |
| 89 | + }) |
| 90 | +}) |
0 commit comments