From ba7ac5d4398db7aa1dc7aeca4a63f86acb6e8de7 Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Tue, 9 Apr 2024 23:08:20 -0400 Subject: [PATCH] test: fix unit tests (#5760) --- .github/workflows/main.yml | 1 - .../queries/getLocalizedSortProperty.spec.ts | 24 ++++++++++--------- packages/plugin-sentry/src/plugin.spec.ts | 2 -- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e2a64fd96..851534eb5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -88,7 +88,6 @@ jobs: tests-unit: runs-on: ubuntu-latest needs: build - if: false # Disable until tests are updated for 3.0 steps: - name: Use Node.js 18 diff --git a/packages/db-mongodb/src/queries/getLocalizedSortProperty.spec.ts b/packages/db-mongodb/src/queries/getLocalizedSortProperty.spec.ts index 55310ca3a..bc1153fa7 100644 --- a/packages/db-mongodb/src/queries/getLocalizedSortProperty.spec.ts +++ b/packages/db-mongodb/src/queries/getLocalizedSortProperty.spec.ts @@ -1,18 +1,20 @@ -import { sanitizeConfig } from 'payload/config' +import { SanitizedConfig, sanitizeConfig } from 'payload/config' import { Config } from 'payload/config' import { getLocalizedSortProperty } from './getLocalizedSortProperty.js' -const config = { +const config = sanitizeConfig({ localization: { locales: ['en', 'es'], + defaultLocale: 'en', + fallback: true, }, -} as Config +} as Config) as SanitizedConfig describe('get localized sort property', () => { it('passes through a non-localized sort property', () => { const result = getLocalizedSortProperty({ segments: ['title'], - config: sanitizeConfig(config), + config, fields: [ { name: 'title', @@ -28,7 +30,7 @@ describe('get localized sort property', () => { it('properly localizes an un-localized sort property', () => { const result = getLocalizedSortProperty({ segments: ['title'], - config: sanitizeConfig(config), + config, fields: [ { name: 'title', @@ -45,7 +47,7 @@ describe('get localized sort property', () => { it('keeps specifically asked-for localized sort properties', () => { const result = getLocalizedSortProperty({ segments: ['title', 'es'], - config: sanitizeConfig(config), + config, fields: [ { name: 'title', @@ -62,7 +64,7 @@ describe('get localized sort property', () => { it('properly localizes nested sort properties', () => { const result = getLocalizedSortProperty({ segments: ['group', 'title'], - config: sanitizeConfig(config), + config, fields: [ { name: 'group', @@ -85,7 +87,7 @@ describe('get localized sort property', () => { it('keeps requested locale with nested sort properties', () => { const result = getLocalizedSortProperty({ segments: ['group', 'title', 'es'], - config: sanitizeConfig(config), + config, fields: [ { name: 'group', @@ -108,7 +110,7 @@ describe('get localized sort property', () => { it('properly localizes field within row', () => { const result = getLocalizedSortProperty({ segments: ['title'], - config: sanitizeConfig(config), + config, fields: [ { type: 'row', @@ -130,7 +132,7 @@ describe('get localized sort property', () => { it('properly localizes field within named tab', () => { const result = getLocalizedSortProperty({ segments: ['tab', 'title'], - config: sanitizeConfig(config), + config, fields: [ { type: 'tabs', @@ -157,7 +159,7 @@ describe('get localized sort property', () => { it('properly localizes field within unnamed tab', () => { const result = getLocalizedSortProperty({ segments: ['title'], - config: sanitizeConfig(config), + config, fields: [ { type: 'tabs', diff --git a/packages/plugin-sentry/src/plugin.spec.ts b/packages/plugin-sentry/src/plugin.spec.ts index 1cb3056ff..83318dacc 100644 --- a/packages/plugin-sentry/src/plugin.spec.ts +++ b/packages/plugin-sentry/src/plugin.spec.ts @@ -34,13 +34,11 @@ describe('plugin', () => { }) function assertPluginRan(config: Config) { - expect(config.admin?.webpack).toBeDefined() expect(config.hooks?.afterError).toBeDefined() expect(config.onInit).toBeDefined() } function assertPluginDidNotRun(config: Config) { - expect(config.admin?.webpack).toBeDefined() expect(config.hooks?.afterError).toBeUndefined() expect(config.onInit).toBeUndefined() }