Skip to content

Commit

Permalink
test: add unit testing (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeworxet committed Nov 15, 2022
1 parent 174c974 commit b8f68b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('#');
}

Expand Down
12 changes: 11 additions & 1 deletion tests/lib/index.spec.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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();
});
});

0 comments on commit b8f68b9

Please sign in to comment.