Skip to content

Commit

Permalink
fix: Correctly set addRequestContentFormat option (#131)
Browse files Browse the repository at this point in the history
* fix: Correctly set addRequestContentFormat option.

* test: Update addRequestContentFormat option tests.
  • Loading branch information
TurtlBbx authored Mar 8, 2023
1 parent a7f157a commit c19ecd6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/runtime/composables/useDrupalCe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export const useDrupalCe = () => {

if (config.addRequestContentFormat) {
useFetchOptions.query = useFetchOptions.query ?? {}
useFetchOptions.query.addRequestContentFormat = config.addRequestContentFormat
useFetchOptions.query._content_format = config.addRequestContentFormat
}

const { data: page, error } = await useFetch(path, useFetchOptions)

if (page?.value?.redirect) {
await navigateTo(page.value.redirect.url, {
external: page.value.redirect.external,
Expand Down
4 changes: 2 additions & 2 deletions test/addRequestContentFormat/json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Module addRequestContentFormat option set to json', async () => {
})
it('is correctly set in query', async () => {
const html = await $fetch('/')
expect(html).toContain('addRequestContentFormat=json')
expect(html).not.toContain('addRequestContentFormat=markup')
expect(html).toContain('_content_format=json')
expect(html).not.toContain('_content_format=markup')
})
})
4 changes: 2 additions & 2 deletions test/addRequestContentFormat/markup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Module addRequestContentFormat set to markup', async () => {
})
it('is correctly set in query', async () => {
const html = await $fetch('/')
expect(html).toContain('addRequestContentFormat=markup')
expect(html).not.toContain('addRequestContentFormat=json')
expect(html).toContain('_content_format=markup')
expect(html).not.toContain('_content_format=json')
})
})
2 changes: 1 addition & 1 deletion test/addRequestContentFormat/unset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ describe('Module addRequestContentFormat not set', async () => {
})
it('is correctly missing in query', async () => {
const html = await $fetch('/')
expect(html).not.toContain('addRequestContentFormat=')
expect(html).not.toContain('_content_format=')
})
})

0 comments on commit c19ecd6

Please sign in to comment.