From c437af00aba8b13a51795b951c25c3a95f84b37c Mon Sep 17 00:00:00 2001 From: Rainer Friederich Date: Fri, 6 Dec 2024 13:49:07 +0100 Subject: [PATCH] fix(next-drupal)!: upgrade tests to new async request objects --- packages/next-drupal/.env.example | 2 +- .../tests/NextDrupalPages/pages-router-methods.test.ts | 2 +- packages/next-drupal/tests/draft/draft.test.ts | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/next-drupal/.env.example b/packages/next-drupal/.env.example index 9c934170..180fd21d 100644 --- a/packages/next-drupal/.env.example +++ b/packages/next-drupal/.env.example @@ -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 diff --git a/packages/next-drupal/tests/NextDrupalPages/pages-router-methods.test.ts b/packages/next-drupal/tests/NextDrupalPages/pages-router-methods.test.ts index 242ca6db..427717f9 100644 --- a/packages/next-drupal/tests/NextDrupalPages/pages-router-methods.test.ts +++ b/packages/next-drupal/tests/NextDrupalPages/pages-router-methods.test.ts @@ -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, diff --git a/packages/next-drupal/tests/draft/draft.test.ts b/packages/next-drupal/tests/draft/draft.test.ts index ac4fec2b..3c9b340f 100644 --- a/packages/next-drupal/tests/draft/draft.test.ts +++ b/packages/next-drupal/tests/draft/draft.test.ts @@ -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) @@ -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) @@ -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) @@ -220,6 +218,8 @@ describe("getDraftData()", () => { cookiesStore.set(draftDataCookie) draftModeStore.enable() - expect(getDraftData()).toMatchObject(draftData) + const draftDataReturn = await getDraftData() + + expect(draftDataReturn).toMatchObject(draftData) }) })