1- import {
2- ParserErrorUnsupportedVersion ,
3- ParserErrorNoJS ,
4- } from '@asyncapi/parser' ;
51import { Options as ParserOptions } from 'json-schema-ref-parser' ;
62
73import { Parser } from '../parser' ;
@@ -28,28 +24,6 @@ const mockParseURLErr = <T extends Error>(err: T) =>
2824describe ( 'Parser' , ( ) => {
2925 describe ( 'parse' , ( ) => {
3026 const parseURL = mockParseURLErr ( new Error ( 'not implemented' ) ) ;
31- test . each `
32- error | desc
33- ${ new ParserErrorUnsupportedVersion ( 'err' ) } | ${ 'ParserErrorUnsupportedVersion is thrown' }
34- ${ new ParserErrorNoJS ( 'test error' ) } | ${ 'ParserErrorNoJS is thrown' }
35- ${ new Error ( 'other error' ) } | ${ 'other error' }
36- ${ {
37- message : 'version' ,
38- parsedJSON : {
39- asyncapi : '1' ,
40- } ,
41- } } | ${ 'invalid version is returned' }
42- ` (
43- 'should return error when $desc' ,
44- async < R extends Error , T extends { error : R ; desc : string } > ( err : T ) => {
45- const parse = mockParseErr ( err . error ) ;
46- const parser = new Parser ( parse , parseURL ) ;
47- await parser . parse ( 'mocked' ) . then ( result => {
48- expect ( result . error ) . toBeTruthy ( ) ;
49- expect ( result . data ) . toBeFalsy ( ) ;
50- } ) ;
51- } ,
52- ) ;
5327
5428 test ( 'should return no errors and data when doc is valid' , async ( ) => {
5529 const doc : AsyncAPI = ( validDoc as any ) as AsyncAPI ;
@@ -64,28 +38,6 @@ describe('Parser', () => {
6438
6539 describe ( 'parseURL' , ( ) => {
6640 const parse = mockParseErr ( new Error ( 'not implemented' ) ) ;
67- test . each `
68- error | desc
69- ${ new ParserErrorUnsupportedVersion ( 'err' ) } | ${ 'ParserErrorUnsupportedVersion is thrown' }
70- ${ new ParserErrorNoJS ( 'test error' ) } | ${ 'ParserErrorNoJS is thrown' }
71- ${ new Error ( 'other error' ) } | ${ 'other error' }
72- ${ {
73- message : 'version' ,
74- parsedJSON : {
75- asyncapi : '1' ,
76- } ,
77- } } | ${ 'invalid version is returned' }
78- ` (
79- 'should return error when $desc' ,
80- async < R extends Error , T extends { error : R ; desc : string } > ( err : T ) => {
81- const parseURL = mockParseURLErr ( err . error ) ;
82- const parser = new Parser ( parse , parseURL ) ;
83- await parser . parseFromUrl ( { url : 'mocked' } ) . then ( result => {
84- expect ( result . error ) . toBeTruthy ( ) ;
85- expect ( result . data ) . toBeFalsy ( ) ;
86- } ) ;
87- } ,
88- ) ;
8941
9042 test ( 'should return no errors and data when doc is valid' , async ( ) => {
9143 const doc : AsyncAPI = ( validDoc as any ) as AsyncAPI ;
0 commit comments