From a5c1d1dad237b9318ba6b764843f7d09e5661071 Mon Sep 17 00:00:00 2001 From: Dany Castillo <31006608+dcastil@users.noreply.github.com> Date: Sun, 18 Aug 2024 14:28:21 +0200 Subject: [PATCH] migrate test suite to vitest --- tests/arbitrary-properties.test.ts | 2 ++ tests/arbitrary-values.test.ts | 2 ++ tests/arbitrary-variants.test.ts | 2 ++ tests/class-group-conflicts.test.ts | 2 ++ tests/class-map.test.ts | 2 ++ tests/colors.test.ts | 2 ++ tests/conflicts-across-class-groups.test.ts | 2 ++ tests/content-utilities.test.ts | 2 ++ tests/create-tailwind-merge.test.ts | 2 ++ tests/default-config.test.ts | 2 ++ tests/docs-examples.test.ts | 1 + tests/experimental-parse-class-name.test.ts | 2 ++ tests/extend-tailwind-merge.test.ts | 2 ++ tests/important-modifier.test.ts | 2 ++ tests/lazy-initialization.test.ts | 4 +++- tests/merge-configs.test.ts | 2 ++ tests/modifiers.test.ts | 2 ++ tests/negative-values.test.ts | 2 ++ tests/non-conflicting-classes.test.ts | 2 ++ tests/non-tailwind-classes.test.ts | 2 ++ tests/per-side-border-colors.test.ts | 2 ++ tests/prefixes.test.ts | 2 ++ tests/pseudo-variants.test.ts | 2 ++ tests/public-api.test.ts | 5 ++++- tests/separators.test.ts | 2 ++ tests/standalone-classes.test.ts | 2 ++ tests/tailwind-css-versions.test.ts | 2 ++ tests/theme.test.ts | 2 ++ tests/tsconfig.json | 5 ++++- tests/tw-join.test.ts | 2 ++ tests/tw-merge.test.ts | 2 ++ tests/type-generics.test.ts | 2 ++ tests/validators.test.ts | 2 ++ tests/wonky-inputs.test.ts | 2 ++ 34 files changed, 72 insertions(+), 3 deletions(-) diff --git a/tests/arbitrary-properties.test.ts b/tests/arbitrary-properties.test.ts index 72b7c8c3..af933bcc 100644 --- a/tests/arbitrary-properties.test.ts +++ b/tests/arbitrary-properties.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('handles arbitrary property conflicts correctly', () => { diff --git a/tests/arbitrary-values.test.ts b/tests/arbitrary-values.test.ts index 8d485be1..aa64955c 100644 --- a/tests/arbitrary-values.test.ts +++ b/tests/arbitrary-values.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('handles simple conflicts with arbitrary values correctly', () => { diff --git a/tests/arbitrary-variants.test.ts b/tests/arbitrary-variants.test.ts index 48080b0d..a3414a4c 100644 --- a/tests/arbitrary-variants.test.ts +++ b/tests/arbitrary-variants.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('basic arbitrary variants', () => { diff --git a/tests/class-group-conflicts.test.ts b/tests/class-group-conflicts.test.ts index ff16c683..e5779ced 100644 --- a/tests/class-group-conflicts.test.ts +++ b/tests/class-group-conflicts.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('merges classes from same group correctly', () => { diff --git a/tests/class-map.test.ts b/tests/class-map.test.ts index f1f1c120..ce8f90d3 100644 --- a/tests/class-map.test.ts +++ b/tests/class-map.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { getDefaultConfig } from '../src' import { ClassPartObject, createClassMap } from '../src/lib/class-group-utils' diff --git a/tests/colors.test.ts b/tests/colors.test.ts index 1d653f14..727553a8 100644 --- a/tests/colors.test.ts +++ b/tests/colors.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('handles color conflicts properly', () => { diff --git a/tests/conflicts-across-class-groups.test.ts b/tests/conflicts-across-class-groups.test.ts index af91a7a6..a2571adb 100644 --- a/tests/conflicts-across-class-groups.test.ts +++ b/tests/conflicts-across-class-groups.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('handles conflicts across class groups correctly', () => { diff --git a/tests/content-utilities.test.ts b/tests/content-utilities.test.ts index db8de92c..bab7a71d 100644 --- a/tests/content-utilities.test.ts +++ b/tests/content-utilities.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('merges content utilities correctly', () => { diff --git a/tests/create-tailwind-merge.test.ts b/tests/create-tailwind-merge.test.ts index 1c34716e..613d6f8c 100644 --- a/tests/create-tailwind-merge.test.ts +++ b/tests/create-tailwind-merge.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { createTailwindMerge } from '../src' test('createTailwindMerge works with single config function', () => { diff --git a/tests/default-config.test.ts b/tests/default-config.test.ts index d9dcfcef..3524dd28 100644 --- a/tests/default-config.test.ts +++ b/tests/default-config.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { getDefaultConfig } from '../src' import { Config, DefaultClassGroupIds, DefaultThemeGroupIds } from '../src/lib/types' diff --git a/tests/docs-examples.test.ts b/tests/docs-examples.test.ts index f0224aae..669dc933 100644 --- a/tests/docs-examples.test.ts +++ b/tests/docs-examples.test.ts @@ -1,6 +1,7 @@ import fs from 'fs' import globby from 'globby' +import { expect, test } from 'vitest' import { twMerge } from '../src' diff --git a/tests/experimental-parse-class-name.test.ts b/tests/experimental-parse-class-name.test.ts index 889b0c43..6c77703c 100644 --- a/tests/experimental-parse-class-name.test.ts +++ b/tests/experimental-parse-class-name.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { extendTailwindMerge } from '../src' test('default case', () => { diff --git a/tests/extend-tailwind-merge.test.ts b/tests/extend-tailwind-merge.test.ts index bbbbfd72..1533faec 100644 --- a/tests/extend-tailwind-merge.test.ts +++ b/tests/extend-tailwind-merge.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { extendTailwindMerge } from '../src' test('extendTailwindMerge works correctly with single config', () => { diff --git a/tests/important-modifier.test.ts b/tests/important-modifier.test.ts index 46a5427c..c5cdfe7d 100644 --- a/tests/important-modifier.test.ts +++ b/tests/important-modifier.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('merges tailwind classes with important modifier correctly', () => { diff --git a/tests/lazy-initialization.test.ts b/tests/lazy-initialization.test.ts index 5a937789..569c540d 100644 --- a/tests/lazy-initialization.test.ts +++ b/tests/lazy-initialization.test.ts @@ -1,7 +1,9 @@ +import { expect, test, vi } from 'vitest' + import { createTailwindMerge, getDefaultConfig } from '../src' test('lazy initialization', () => { - const initMock = jest.fn(getDefaultConfig) + const initMock = vi.fn(getDefaultConfig) const twMerge = createTailwindMerge(initMock) expect(initMock).not.toHaveBeenCalled() diff --git a/tests/merge-configs.test.ts b/tests/merge-configs.test.ts index 5e98ceb0..6fa86c67 100644 --- a/tests/merge-configs.test.ts +++ b/tests/merge-configs.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { mergeConfigs } from '../src' test('mergeConfigs has correct behavior', () => { diff --git a/tests/modifiers.test.ts b/tests/modifiers.test.ts index 18152566..df948ba2 100644 --- a/tests/modifiers.test.ts +++ b/tests/modifiers.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { createTailwindMerge, twMerge } from '../src' test('conflicts across prefix modifiers', () => { diff --git a/tests/negative-values.test.ts b/tests/negative-values.test.ts index a9bfcb02..73880f6d 100644 --- a/tests/negative-values.test.ts +++ b/tests/negative-values.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('handles negative value conflicts correctly', () => { diff --git a/tests/non-conflicting-classes.test.ts b/tests/non-conflicting-classes.test.ts index 27015f5f..f0a17110 100644 --- a/tests/non-conflicting-classes.test.ts +++ b/tests/non-conflicting-classes.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('merges non-conflicting classes correctly', () => { diff --git a/tests/non-tailwind-classes.test.ts b/tests/non-tailwind-classes.test.ts index c4e828f0..6aa5d831 100644 --- a/tests/non-tailwind-classes.test.ts +++ b/tests/non-tailwind-classes.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('does not alter non-tailwind classes', () => { diff --git a/tests/per-side-border-colors.test.ts b/tests/per-side-border-colors.test.ts index 697339d2..81f8489c 100644 --- a/tests/per-side-border-colors.test.ts +++ b/tests/per-side-border-colors.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('merges classes with per-side border colors correctly', () => { diff --git a/tests/prefixes.test.ts b/tests/prefixes.test.ts index 02fc572a..cf17f0b7 100644 --- a/tests/prefixes.test.ts +++ b/tests/prefixes.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { extendTailwindMerge } from '../src' test('prefix working correctly', () => { diff --git a/tests/pseudo-variants.test.ts b/tests/pseudo-variants.test.ts index c2644a62..61f39cff 100644 --- a/tests/pseudo-variants.test.ts +++ b/tests/pseudo-variants.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('handles pseudo variants conflicts properly', () => { diff --git a/tests/public-api.test.ts b/tests/public-api.test.ts index 2fa33cad..91f1fda6 100644 --- a/tests/public-api.test.ts +++ b/tests/public-api.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { ClassNameValue, ClassValidator, @@ -18,7 +20,7 @@ test('has correct export types', () => { expect(twMerge).toStrictEqual(expect.any(Function)) expect(createTailwindMerge).toStrictEqual(expect.any(Function)) expect(getDefaultConfig).toStrictEqual(expect.any(Function)) - expect(validators).toEqual({ + expect(validators).toMatchObject({ isAny: expect.any(Function), isArbitraryLength: expect.any(Function), isArbitraryNumber: expect.any(Function), @@ -33,6 +35,7 @@ test('has correct export types', () => { isNumber: expect.any(Function), isTshirtSize: expect.any(Function), }) + expect(Object.keys(validators)).toHaveLength(13) expect(mergeConfigs).toStrictEqual(expect.any(Function)) expect(extendTailwindMerge).toStrictEqual(expect.any(Function)) expect(twJoin).toStrictEqual(expect.any(Function)) diff --git a/tests/separators.test.ts b/tests/separators.test.ts index 703e4eb6..0064a91e 100644 --- a/tests/separators.test.ts +++ b/tests/separators.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { extendTailwindMerge } from '../src' test('single character separator working correctly', () => { diff --git a/tests/standalone-classes.test.ts b/tests/standalone-classes.test.ts index c8878326..5f58f132 100644 --- a/tests/standalone-classes.test.ts +++ b/tests/standalone-classes.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('merges standalone classes from same group correctly', () => { diff --git a/tests/tailwind-css-versions.test.ts b/tests/tailwind-css-versions.test.ts index 3c08b607..2ac802fc 100644 --- a/tests/tailwind-css-versions.test.ts +++ b/tests/tailwind-css-versions.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('supports Tailwind CSS v3.3 features', () => { diff --git a/tests/theme.test.ts b/tests/theme.test.ts index f5a7a63d..a05997c4 100644 --- a/tests/theme.test.ts +++ b/tests/theme.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { extendTailwindMerge, fromTheme } from '../src' test('theme scale can be extended', () => { diff --git a/tests/tsconfig.json b/tests/tsconfig.json index a5b5ed3e..43000660 100644 --- a/tests/tsconfig.json +++ b/tests/tsconfig.json @@ -1,4 +1,7 @@ { "extends": "../tsconfig.json", - "include": ["./**/*"] + "include": ["./**/*"], + "compilerOptions": { + "resolveJsonModule": true + } } diff --git a/tests/tw-join.test.ts b/tests/tw-join.test.ts index 4add8337..bebdba5b 100644 --- a/tests/tw-join.test.ts +++ b/tests/tw-join.test.ts @@ -7,6 +7,8 @@ * Original code has MIT license: Copyright (c) Luke Edwards (lukeed.com) */ +import { expect, test } from 'vitest' + import { twJoin } from '../src' test('strings', () => { diff --git a/tests/tw-merge.test.ts b/tests/tw-merge.test.ts index ff63402a..8d6a7c07 100644 --- a/tests/tw-merge.test.ts +++ b/tests/tw-merge.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('twMerge', () => { diff --git a/tests/type-generics.test.ts b/tests/type-generics.test.ts index 0ff25baa..0b820a7b 100644 --- a/tests/type-generics.test.ts +++ b/tests/type-generics.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { extendTailwindMerge, fromTheme, getDefaultConfig, mergeConfigs } from '../src' import { GenericConfig } from '../src/lib/types' diff --git a/tests/validators.test.ts b/tests/validators.test.ts index ba7bdf1a..a7d71512 100644 --- a/tests/validators.test.ts +++ b/tests/validators.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { validators } from '../src' const { diff --git a/tests/wonky-inputs.test.ts b/tests/wonky-inputs.test.ts index 32cf87d9..db1cdd24 100644 --- a/tests/wonky-inputs.test.ts +++ b/tests/wonky-inputs.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from 'vitest' + import { twMerge } from '../src' test('handles wonky inputs', () => {