Skip to content

Commit 0a44196

Browse files
committed
feat: Update tests
1 parent 11f601d commit 0a44196

File tree

13 files changed

+34
-26
lines changed

13 files changed

+34
-26
lines changed

test/document-group.test.ts

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { Editor, loadFileAsString, LocalRegistry } from './helpers'
18-
import { BUILD_TYPE, REST_API_TYPE } from '../src'
17+
import { Editor, loadFileAsString, LocalRegistry, VERSIONS_PATH } from './helpers'
18+
import { BUILD_TYPE, PACKAGE, PackageNotifications, REST_API_TYPE } from '../src'
1919
import { load } from 'js-yaml'
2020

2121
const GROUP_NAME = 'manualGroup'
@@ -68,8 +68,8 @@ describe('Document Group test', () => {
6868
await runMergeOperationsCase('basic-documents-for-merge')
6969
})
7070

71-
test('should have keep a few operations in one path', async () => {
72-
const pkg = LocalRegistry.openPackage('document-group/few-operations-in-one-path', groupToOnePathOperationIdsMap)
71+
test('should have keep a multiple operations in one path', async () => {
72+
const pkg = LocalRegistry.openPackage('document-group/multiple-operations-in-one-path', groupToOnePathOperationIdsMap)
7373
const editor = await Editor.openProject(pkg.packageId, pkg)
7474
await pkg.publish(pkg.packageId, { packageId: pkg.packageId })
7575

@@ -159,7 +159,7 @@ describe('Document Group test', () => {
159159
})
160160

161161
describe('PathItems tests', () => {
162-
test('should have documents with keep pathItems in components', async () => {
162+
test('should have save pathItems in components', async () => {
163163
const pkg = LocalRegistry.openPackage('document-group/operations-in-pathitems', groupToOperationIdsMap)
164164
const editor = await Editor.openProject(pkg.packageId, pkg)
165165
await pkg.publish(pkg.packageId, { packageId: pkg.packageId })
@@ -175,8 +175,8 @@ describe('Document Group test', () => {
175175
}
176176
})
177177

178-
test('should have keep a few operations in one pathItems', async () => {
179-
const pkg = LocalRegistry.openPackage('document-group/few-operations-in-one-pathitems', groupToOnePathOperationIdsMap)
178+
test('should be saved multiple operations in one pathItems', async () => {
179+
const pkg = LocalRegistry.openPackage('document-group/multiple-operations-in-one-pathitems', groupToOnePathOperationIdsMap)
180180
const editor = await Editor.openProject(pkg.packageId, pkg)
181181
await pkg.publish(pkg.packageId, { packageId: pkg.packageId })
182182

@@ -237,7 +237,7 @@ describe('Document Group test', () => {
237237
}
238238
})
239239

240-
describe('Chain refs', () => {
240+
describe('Chain pathItems Refs', () => {
241241
const COMPONENTS_ITEM_1_PATH = ['components', 'pathItems', 'componentsPathItem1']
242242
test('should have documents with keep pathItems in components', async () => {
243243
const pkg = LocalRegistry.openPackage('document-group/define-pathitems-via-reference-object-chain', groupToOnePathOperationIdsMap)
@@ -272,9 +272,9 @@ describe('Document Group test', () => {
272272
})
273273
})
274274

275-
describe('reference-object', () => {
276-
test('second-level-object-are-the-same-when-overriding-for-response', async () => {
277-
const pkg = LocalRegistry.openPackage('document-group/second-level-object-are-the-same-when-overriding-for-response', groupToOnePathOperationIdsMap)
275+
describe('PathItems Reference Object', () => {
276+
test('second level object are the same when overriding for pathitems response', async () => {
277+
const pkg = LocalRegistry.openPackage('document-group/second-level-object-are-the-same-when-overriding-for-pathitems-response', groupToOnePathOperationIdsMap)
278278
const editor = await Editor.openProject(pkg.packageId, pkg)
279279
await pkg.publish(pkg.packageId, { packageId: pkg.packageId })
280280

@@ -292,8 +292,8 @@ describe('Document Group test', () => {
292292
}
293293
})
294294

295-
test('not-hang-up-when-processing-for-response-which-points-to-itself', async () => {
296-
const pkg = LocalRegistry.openPackage('document-group/not-hang-up-when-processing-for-response-which-points-to-itself', groupToOnePathOperationIdsMap)
295+
test('should not hang up when processing for pathitems response which points to itself', async () => {
296+
const pkg = LocalRegistry.openPackage('document-group/not-hang-up-when-processing-for-pathitems-response-which-points-to-itself', groupToOnePathOperationIdsMap)
297297
const editor = await Editor.openProject(pkg.packageId, pkg)
298298
await pkg.publish(pkg.packageId, { packageId: pkg.packageId })
299299

@@ -306,24 +306,32 @@ describe('Document Group test', () => {
306306
expect(result.documents.size).toEqual(0)
307307
})
308308

309-
test.skip('not-hang-up-when-processing-cycled-chain-for-response', async () => {
310-
const pkg = LocalRegistry.openPackage('document-group/not-hang-up-when-processing-cycled-chain-for-response', groupToOnePathOperationIdsMap)
311-
const editor = await Editor.openProject(pkg.packageId, pkg)
309+
test('should not hang up when processing cycled chain for pathitems response', async () => {
310+
const pkg = LocalRegistry.openPackage('document-group/not-hang-up-when-processing-cycled-chain-for-pathitems-response', groupToOnePathOperationIdsMap)
312311
await pkg.publish(pkg.packageId, { packageId: pkg.packageId })
313312

314-
const result = await editor.run({
315-
packageId: pkg.packageId,
316-
groupName: GROUP_NAME,
317-
buildType: BUILD_TYPE.REDUCED_SOURCE_SPECIFICATIONS,
318-
})
313+
const notificationFile = await loadFileAsString(
314+
VERSIONS_PATH,
315+
`${pkg.packageId}/v1`,
316+
`${PACKAGE.NOTIFICATIONS_FILE_NAME}`,
317+
)
318+
expect(notificationFile).not.toBeNull()
319319

320-
for (const document of Array.from(result.documents.values())) {
321-
expect(Object.keys(document.data.components.pathItems['pathItem1']).length).toEqual(document.operationIds.length)
322-
}
320+
const { notifications } = JSON.parse(notificationFile!) as PackageNotifications
321+
322+
const brokenRefMessages = [
323+
'$ref can\'t be resolved: #/components/responses/SuccessResponse2',
324+
'$ref can\'t be resolved: #/components/responses/SuccessResponse',
325+
]
326+
327+
brokenRefMessages.forEach((message) => {
328+
const found = notifications.some(notification => notification.message === message)
329+
expect(found).toBe(true)
330+
})
323331
})
324332
})
325333

326-
describe('Merge Operations', () => {
334+
describe('Merge Pathitems Operations', () => {
327335
test('should have properly merged documents', async () => {
328336
await runMergeOperationsCase('basic-documents-pathitems-for-merge')
329337
})

test/hash.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('Hash test', () => {
1919
const operationFile = await loadFileAsString(
2020
VERSIONS_PATH,
2121
`${pkg.packageId}/v1`,
22-
`${PACKAGE.OPERATIONS_DIR_NAME}.json`,
22+
`${PACKAGE.OPERATIONS_FILE_NAME}`,
2323
)
2424
expect(operationFile).not.toBeNull()
2525

0 commit comments

Comments
 (0)