Skip to content

Commit

Permalink
fixed tests and linter complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
slim committed Nov 9, 2023
1 parent 19c73ba commit 5758f0e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/hydra/dataProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('Transform a React Admin request to an Hydra request', () => {
perPage: 30,
},
sort: {
order: '',
order: 'ASC',
field: '',
},
filter: {
Expand Down
2 changes: 1 addition & 1 deletion src/hydra/dataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ function dataProvider(
page: 1,
},
filter: { id: params.ids },
sort: { field: '', order: '' },
sort: { field: '', order: 'ASC' },
}).then(({ data }) => ({ data }));
}

Expand Down
20 changes: 11 additions & 9 deletions src/hydra/fetchHydra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getDocumentationUrlFromHeaders,
} from '@api-platform/api-doc-parser';
import jsonld from 'jsonld';
import type { NodeObject } from 'jsonld';
import type { ContextDefinition, NodeObject } from 'jsonld';
import type { JsonLdObj } from 'jsonld/jsonld-spec';
import type { HttpClientOptions, HydraHttpClientResponse } from '../types.js';

Expand Down Expand Up @@ -41,24 +41,26 @@ function fetchHydra(
delete (body as NodeObject).trace;

const documentLoader = (input: string) => {
let options = authOptions;
options.method = "GET";
delete options.body;
const loaderOptions = authOptions;
loaderOptions.method = 'GET';
delete loaderOptions.body;

return fetchJsonLd(input, options).then((response) => {
return fetchJsonLd(input, loaderOptions).then((response) => {
if (!('body' in response)) {
throw new Error(
'An empty response was received when expanding JSON-LD error document.',
);
}
return response;
});
}
};

return documentLoader(getDocumentationUrlFromHeaders(headers))
.then((response) => jsonld.expand(body, {
expandContext: response.document as any
}))
.then((response) =>
jsonld.expand(body, {
expandContext: response.document as ContextDefinition,
}),
)

.then((json) =>
Promise.reject(
Expand Down

0 comments on commit 5758f0e

Please sign in to comment.