Skip to content

Commit

Permalink
fix(next-drupal)!: upgrade tests to new async request objects
Browse files Browse the repository at this point in the history
  • Loading branch information
yobottehg committed Dec 6, 2024
1 parent 4c30157 commit c437af0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/next-drupal/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DRUPAL_BASE_URL=http://drupal
DRUPAL_BASE_URL=http://localhost
DRUPAL_USERNAME=drupal
DRUPAL_PASSWORD=drupal
DRUPAL_CLIENT_ID=next-drupal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, jest, test } from "@jest/globals"
import { GetStaticPropsContext, NextApiRequest, NextApiResponse } from "next"
import { GetStaticPropsContext } from "next"
import { DRAFT_DATA_COOKIE_NAME, NextDrupalPages } from "../../src"
import {
BASE_URL,
Expand Down
8 changes: 4 additions & 4 deletions packages/next-drupal/tests/draft/draft.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe("enableDraftMode()", () => {

describe("disableDraftMode()", () => {
test("draft data cookie was deleted", async () => {
disableDraftMode()
await disableDraftMode()
const cookiesStore = await cookies()

expect(cookiesStore).toHaveBeenCalledTimes(1)
Expand Down Expand Up @@ -185,7 +185,6 @@ describe("getDraftData()", () => {
draftModeStore.enable()

const data = await getDraftData()
expect(draftMode).toHaveBeenCalledTimes(1)
expect(draftModeStore.isEnabled).toBe(true)
expect(cookiesStore.has).toHaveBeenCalledWith(DRAFT_DATA_COOKIE_NAME)
expect(cookiesStore.has).toHaveBeenCalledTimes(1)
Expand All @@ -204,7 +203,6 @@ describe("getDraftData()", () => {
draftModeStore.enable()

const data = await getDraftData()
expect(draftModeStore).toHaveBeenCalledTimes(1)
expect(draftModeStore.isEnabled).toBe(true)
expect(cookiesStore.has).toHaveBeenCalledWith(DRAFT_DATA_COOKIE_NAME)
expect(cookiesStore.has).toHaveBeenCalledTimes(1)
Expand All @@ -220,6 +218,8 @@ describe("getDraftData()", () => {
cookiesStore.set(draftDataCookie)
draftModeStore.enable()

expect(getDraftData()).toMatchObject(draftData)
const draftDataReturn = await getDraftData()

expect(draftDataReturn).toMatchObject(draftData)
})
})

0 comments on commit c437af0

Please sign in to comment.