Skip to content

Commit

Permalink
fix(next-drupal): update TypeScript definition for translatePath and …
Browse files Browse the repository at this point in the history
…translatePathFromContext

Fixes #359
  • Loading branch information
shadcn authored Feb 14, 2024
1 parent ac704e3 commit 9f6ae58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/next-drupal/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ export class DrupalClient {
async translatePath(
path: string,
options?: JsonApiWithAuthOptions
): Promise<DrupalTranslatedPath> {
): Promise<DrupalTranslatedPath | null> {
options = {
withAuth: this.withAuth,
...options,
Expand Down Expand Up @@ -927,7 +927,7 @@ export class DrupalClient {
options?: {
pathPrefix?: PathPrefix
} & JsonApiWithAuthOptions
): Promise<DrupalTranslatedPath> {
): Promise<DrupalTranslatedPath | null> {
options = {
pathPrefix: "/",
...options,
Expand Down
14 changes: 8 additions & 6 deletions packages/next-drupal/tests/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1445,13 +1445,15 @@ describe("getResourceFromContext", () => {
},
}

const recipe = await client.getResourceFromContext(path, context, {
params: {
"fields[node--recipe]": "title,path,status",
},
})
if (path) {
const recipe = await client.getResourceFromContext(path, context, {
params: {
"fields[node--recipe]": "title,path,status",
},
})

await expect(recipe).toMatchSnapshot()
await expect(recipe).toMatchSnapshot()
}
})
})

Expand Down

0 comments on commit 9f6ae58

Please sign in to comment.