Skip to content

Commit

Permalink
migrate test suite to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
dcastil committed Aug 18, 2024
1 parent bca0970 commit a5c1d1d
Show file tree
Hide file tree
Showing 34 changed files with 72 additions and 3 deletions.
2 changes: 2 additions & 0 deletions tests/arbitrary-properties.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('handles arbitrary property conflicts correctly', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/arbitrary-values.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('handles simple conflicts with arbitrary values correctly', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/arbitrary-variants.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('basic arbitrary variants', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/class-group-conflicts.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('merges classes from same group correctly', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/class-map.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { getDefaultConfig } from '../src'
import { ClassPartObject, createClassMap } from '../src/lib/class-group-utils'

Expand Down
2 changes: 2 additions & 0 deletions tests/colors.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('handles color conflicts properly', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/conflicts-across-class-groups.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('handles conflicts across class groups correctly', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/content-utilities.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('merges content utilities correctly', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/create-tailwind-merge.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { createTailwindMerge } from '../src'

test('createTailwindMerge works with single config function', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/default-config.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { getDefaultConfig } from '../src'
import { Config, DefaultClassGroupIds, DefaultThemeGroupIds } from '../src/lib/types'

Expand Down
1 change: 1 addition & 0 deletions tests/docs-examples.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'fs'

import globby from 'globby'
import { expect, test } from 'vitest'

import { twMerge } from '../src'

Expand Down
2 changes: 2 additions & 0 deletions tests/experimental-parse-class-name.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { extendTailwindMerge } from '../src'

test('default case', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/extend-tailwind-merge.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { extendTailwindMerge } from '../src'

test('extendTailwindMerge works correctly with single config', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/important-modifier.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('merges tailwind classes with important modifier correctly', () => {
Expand Down
4 changes: 3 additions & 1 deletion tests/lazy-initialization.test.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 2 additions & 0 deletions tests/merge-configs.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { mergeConfigs } from '../src'

test('mergeConfigs has correct behavior', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/modifiers.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { createTailwindMerge, twMerge } from '../src'

test('conflicts across prefix modifiers', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/negative-values.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('handles negative value conflicts correctly', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/non-conflicting-classes.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('merges non-conflicting classes correctly', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/non-tailwind-classes.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('does not alter non-tailwind classes', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/per-side-border-colors.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('merges classes with per-side border colors correctly', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/prefixes.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { extendTailwindMerge } from '../src'

test('prefix working correctly', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/pseudo-variants.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('handles pseudo variants conflicts properly', () => {
Expand Down
5 changes: 4 additions & 1 deletion tests/public-api.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import {
ClassNameValue,
ClassValidator,
Expand All @@ -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),
Expand All @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions tests/separators.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { extendTailwindMerge } from '../src'

test('single character separator working correctly', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/standalone-classes.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('merges standalone classes from same group correctly', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/tailwind-css-versions.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('supports Tailwind CSS v3.3 features', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/theme.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { extendTailwindMerge, fromTheme } from '../src'

test('theme scale can be extended', () => {
Expand Down
5 changes: 4 additions & 1 deletion tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"extends": "../tsconfig.json",
"include": ["./**/*"]
"include": ["./**/*"],
"compilerOptions": {
"resolveJsonModule": true
}
}
2 changes: 2 additions & 0 deletions tests/tw-join.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* Original code has MIT license: Copyright (c) Luke Edwards <[email protected]> (lukeed.com)
*/

import { expect, test } from 'vitest'

import { twJoin } from '../src'

test('strings', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/tw-merge.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('twMerge', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/type-generics.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { extendTailwindMerge, fromTheme, getDefaultConfig, mergeConfigs } from '../src'
import { GenericConfig } from '../src/lib/types'

Expand Down
2 changes: 2 additions & 0 deletions tests/validators.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { validators } from '../src'

const {
Expand Down
2 changes: 2 additions & 0 deletions tests/wonky-inputs.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect, test } from 'vitest'

import { twMerge } from '../src'

test('handles wonky inputs', () => {
Expand Down

0 comments on commit a5c1d1d

Please sign in to comment.