Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add unit testing #99

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});