@@ -1149,7 +1149,7 @@ test("parse a Hydra documentation without authorization", () => {
11491149 } ) ;
11501150} ) ;
11511151
1152- test ( 'Parse entrypoint without "@type" key' , ( ) => {
1152+ test ( 'Parse entrypoint without "@type" key' , async ( ) => {
11531153 const entrypoint = `{
11541154 "@context": {
11551155 "@vocab": "http://localhost/docs.jsonld#",
@@ -1175,12 +1175,18 @@ test('Parse entrypoint without "@type" key', () => {
11751175
11761176 fetch . mockResponses ( [ entrypoint , init ] , [ docs , init ] ) ;
11771177
1178- parseHydraDocumentation ( "http://localhost/" ) . catch ( data => {
1179- expect ( data . message ) . toBe ( 'The API entrypoint has no "@type" key.' ) ;
1180- } ) ;
1178+ const expectedError = { message : "" } ;
1179+
1180+ try {
1181+ await parseHydraDocumentation ( "http://localhost/" ) ;
1182+ } catch ( error ) {
1183+ expectedError . message = error . message ;
1184+ }
1185+
1186+ expect ( expectedError . message ) . toBe ( 'The API entrypoint has no "@type" key.' ) ;
11811187} ) ;
11821188
1183- test ( 'Parse entrypoint class without "supportedClass" key' , ( ) => {
1189+ test ( 'Parse entrypoint class without "supportedClass" key' , async ( ) => {
11841190 const docs = `{
11851191"@context": {
11861192 "@vocab": "http://localhost/docs.jsonld#",
@@ -1218,14 +1224,20 @@ test('Parse entrypoint class without "supportedClass" key', () => {
12181224
12191225 fetch . mockResponses ( [ entrypoint , init ] , [ docs , init ] ) ;
12201226
1221- parseHydraDocumentation ( "http://localhost/" ) . catch ( data => {
1222- expect ( data . message ) . toBe (
1223- 'The API documentation has no "http://www.w3.org/ns/hydra/core#supportedClass" key or its value is not an array.'
1224- ) ;
1225- } ) ;
1227+ const expectedError = { message : "" } ;
1228+
1229+ try {
1230+ await parseHydraDocumentation ( "http://localhost/" ) ;
1231+ } catch ( error ) {
1232+ expectedError . message = error . message ;
1233+ }
1234+
1235+ expect ( expectedError . message ) . toBe (
1236+ 'The API documentation has no "http://www.w3.org/ns/hydra/core#supportedClass" key or its value is not an array.'
1237+ ) ;
12261238} ) ;
12271239
1228- test ( 'Parse entrypoint class without "supportedProperty" key' , ( ) => {
1240+ test ( 'Parse entrypoint class without "supportedProperty" key' , async ( ) => {
12291241 const docs = `{
12301242"@context": {
12311243 "@vocab": "http://localhost/docs.jsonld#",
@@ -1276,33 +1288,51 @@ test('Parse entrypoint class without "supportedProperty" key', () => {
12761288
12771289 fetch . mockResponses ( [ entrypoint , init ] , [ docs , init ] ) ;
12781290
1279- parseHydraDocumentation ( "http://localhost/" ) . catch ( data => {
1280- expect ( data . message ) . toBe (
1281- 'The entrypoint definition has no "http://www.w3.org/ns/hydra/core#supportedProperty" key or it is not an array.'
1282- ) ;
1283- } ) ;
1291+ const expectedError = { message : "" } ;
1292+
1293+ try {
1294+ await parseHydraDocumentation ( "http://localhost/" ) ;
1295+ } catch ( error ) {
1296+ expectedError . message = error . message ;
1297+ }
1298+
1299+ expect ( expectedError . message ) . toBe (
1300+ 'The entrypoint definition has no "http://www.w3.org/ns/hydra/core#supportedProperty" key or it is not an array.'
1301+ ) ;
12841302} ) ;
12851303
1286- test ( "Invalid docs JSON" , ( ) => {
1304+ test ( "Invalid docs JSON" , async ( ) => {
12871305 const docs = `{foo,}` ;
12881306
12891307 fetch . mockResponses ( [ entrypoint , init ] , [ docs , init ] ) ;
12901308
1291- parseHydraDocumentation ( "http://localhost/" ) . catch ( data => {
1292- expect ( data ) . toHaveProperty ( "api" ) ;
1293- expect ( data ) . toHaveProperty ( "response" ) ;
1294- expect ( data ) . toHaveProperty ( "status" ) ;
1295- } ) ;
1309+ let expectedError = { } ;
1310+
1311+ try {
1312+ await parseHydraDocumentation ( "http://localhost/" ) ;
1313+ } catch ( error ) {
1314+ expectedError = error ;
1315+ }
1316+
1317+ expect ( expectedError ) . toHaveProperty ( "api" ) ;
1318+ expect ( expectedError ) . toHaveProperty ( "response" ) ;
1319+ expect ( expectedError ) . toHaveProperty ( "status" ) ;
12961320} ) ;
12971321
1298- test ( "Invalid entrypoint JSON" , ( ) => {
1322+ test ( "Invalid entrypoint JSON" , async ( ) => {
12991323 const entrypoint = `{foo,}` ;
13001324
13011325 fetch . mockResponses ( [ entrypoint , init ] , [ docs , init ] ) ;
13021326
1303- parseHydraDocumentation ( "http://localhost/" ) . catch ( data => {
1304- expect ( data ) . toHaveProperty ( "api" ) ;
1305- expect ( data ) . toHaveProperty ( "response" ) ;
1306- expect ( data ) . toHaveProperty ( "status" ) ;
1307- } ) ;
1327+ let expectedError = { } ;
1328+
1329+ try {
1330+ await parseHydraDocumentation ( "http://localhost/" ) ;
1331+ } catch ( error ) {
1332+ expectedError = error ;
1333+ }
1334+
1335+ expect ( expectedError ) . toHaveProperty ( "api" ) ;
1336+ expect ( expectedError ) . toHaveProperty ( "response" ) ;
1337+ expect ( expectedError ) . toHaveProperty ( "status" ) ;
13081338} ) ;
0 commit comments