From 5f2feec0134f312a9f882abaf11f0e671feaadd3 Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Thu, 20 Jun 2024 17:06:48 +0200 Subject: [PATCH] test: then & catch --- packages/openapi-parser/src/pipeline.test.ts | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/openapi-parser/src/pipeline.test.ts b/packages/openapi-parser/src/pipeline.test.ts index 59e3e93..be09305 100644 --- a/packages/openapi-parser/src/pipeline.test.ts +++ b/packages/openapi-parser/src/pipeline.test.ts @@ -361,4 +361,39 @@ describe('pipeline', () => { 'Can’t resolve reference: #/components/requestBodies/DoesNotExist', ) }) + + it('works with then & catch', async () => { + return new Promise((resolve, reject) => { + openapi() + .load({ + openapi: '3.1.0', + info: { + title: 'Hello World', + }, + paths: { + '/foobar': { + post: { + requestBody: { + $ref: '#/components/requestBodies/DoesNotExist', + }, + }, + }, + }, + }) + .validate({ + throwOnError: true, + }) + .get() + .then(() => { + reject() + }) + .catch((error) => { + expect(error.message).toBe( + 'Can’t resolve reference: #/components/requestBodies/DoesNotExist', + ) + + resolve(null) + }) + }) + }) })