diff --git a/src/parser.ts b/src/parser.ts index 6196dcc..f831a62 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -41,7 +41,7 @@ function crawlChannelPropertiesForRefs(JSONSchema: AsyncAPIObject) { * @returns {boolean} * @private */ -function isExternalReference(ref: string): boolean { +export function isExternalReference(ref: string): boolean { return typeof ref === 'string' && !ref.startsWith('#'); } diff --git a/tests/lib/index.spec.ts b/tests/lib/index.spec.ts index b285340..d34f33a 100644 --- a/tests/lib/index.spec.ts +++ b/tests/lib/index.spec.ts @@ -1,11 +1,12 @@ import { describe, expect, test } from '@jest/globals'; import bundle from '../../src'; +import { isExternalReference } from '../../src/parser'; import fs from 'fs'; import path from 'path'; import type { ReferenceObject } from '../../src/spec-types'; -describe('bundler should ', () => { +describe('[integration testing] bundler should ', () => { test('should return bundled doc', async () => { const files = ['./tests/camera.yml', './tests/audio.yml']; const response = await bundle( @@ -77,3 +78,12 @@ describe('bundler should ', () => { ).resolves; }); }); + +describe('[unit testing]', () => { + test('`isExternalReference()` should return `true` on external reference', () => { + expect(isExternalReference('./components/messages/UserSignedUp')).toBeTruthy(); + }); + test('`isExternalReference()` should return `false` on local reference', () => { + expect(isExternalReference('#/components/messages/UserSignedUp')).toBeFalsy(); + }); +});