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

fix: add check that $ref value is a string (#92) #94

Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: add check that $ref value is a string (#92)
Co-authored-by: Maciej Urbańczyk <[email protected]>
  • Loading branch information
aeworxet and magicmatatjahu committed Nov 3, 2022
commit e42cf8ddc17915907740bbbaffb835d25085b956
44 changes: 21 additions & 23 deletions tests/lib/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, test } from '@jest/globals';
import { describe, expect, test, jest } from '@jest/globals';
import bundle from '../../src';
import fs from 'fs';
import path from 'path';
Expand Down Expand Up @@ -43,33 +43,31 @@ describe('bundler should ', () => {

test('should not throw if value of `$ref` is not a string', async () => {
const files = ['./tests/wrong-ref-not-string.yaml'];
const response = await bundle(
files.map(file =>
fs.readFileSync(path.resolve(process.cwd(), file), 'utf-8')
),
{
referenceIntoComponents: true,
}
);

const result = response.json();

expect(result).toBeDefined();
expect(
await bundle(
files.map(file =>
fs.readFileSync(path.resolve(process.cwd(), file), 'utf-8')
),
{
referenceIntoComponents: true,
}
)
).resolves;
});

test('should not throw if value of `$ref` is absent', async () => {
const files = ['./tests/wrong-ref-absent.yaml'];
const response = await bundle(
files.map(file =>
fs.readFileSync(path.resolve(process.cwd(), file), 'utf-8')
),
{
referenceIntoComponents: true,
}
);

const result = response.json();

expect(result).toBeDefined();
expect(
await bundle(
files.map(file =>
fs.readFileSync(path.resolve(process.cwd(), file), 'utf-8')
),
{
referenceIntoComponents: true,
}
)
).resolves;
});
});