Skip to content

Commit

Permalink
Deprecate jest in favor of vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed May 21, 2024
1 parent f3431ad commit cbb78b3
Show file tree
Hide file tree
Showing 23 changed files with 160 additions and 160 deletions.
24 changes: 12 additions & 12 deletions packages/language-service/tests/edit-syntax-colors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,50 +21,50 @@ const expectEditedColors = async ({ before, after }: { before: string, after: st
}] as ColorPresentation[])
}

test('hex', async () => {
test.concurrent('hex', async () => {
await expectEditedColors({ before: '#333333', after: '#666666' })
})

test('variable', async () => {
test.concurrent('variable', async () => {
await expectEditedColors({ before: 'blue-50/.5', after: 'rgb(112|141|200/0.5)' })
})

test('rgb', async () => {
test.concurrent('rgb', async () => {
await expectEditedColors({ before: 'rgb(0|255|145)', after: 'rgb(180|218|201)' })
})

test('rgba', async () => {
test.concurrent('rgba', async () => {
await expectEditedColors({ before: 'rgba(255|0|0/.5)', after: 'rgb(207|129|129/0.5)' })
})

test('hsl', async () => {
test.concurrent('hsl', async () => {
await expectEditedColors({ before: 'hsl(50|80%|40%)', after: 'hsl(230|80%|40%)' })
})

test('hsla', async () => {
test.concurrent('hsla', async () => {
await expectEditedColors({ before: 'hsla(50|80%|40%/.5)', after: 'hsl(133|80%|40%/0.5)' })
})

test('hwb', async () => {
test.concurrent('hwb', async () => {
await expectEditedColors({ before: 'hwb(12|50%|10%)', after: 'hwb(332|50%|10%)' })
})

test('lab', async () => {
test.concurrent('lab', async () => {
await expectEditedColors({ before: 'lab(52%|40|60)', after: 'lab(67%|-35|-20)' })
})

test('lch', async () => {
test.concurrent('lch', async () => {
await expectEditedColors({ before: 'lch(50%|72|50)', after: 'lch(70%|82|139)' })
})

test('oklab', async () => {
test.concurrent('oklab', async () => {
await expectEditedColors({ before: 'oklab(50%|0.1|0.11)', after: 'oklab(38%|0.0877|-0.1906)' })
})

test('oklch', async () => {
test.concurrent('oklch', async () => {
await expectEditedColors({ before: 'oklch(40%|0.1|21)', after: 'oklch(54%|0.0951|115)' })
})

test('hex to hex8', async () => {
test.concurrent('hex to hex8', async () => {
await expectEditedColors({ before: '#333333', after: '#66666600' })
})
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { test, it, expect, describe } from 'vitest'
import { expectClassPosition } from './test'

test('clsx', () => {
test.concurrent('clsx', () => {
const target = 'class-b'
const contents = ['const classes = clsx("class-a ', target, '")']
expectClassPosition(target, contents, 'js')
})

test('styled', () => {
test.concurrent('styled', () => {
const target = 'class-b'
const contents = ['const Button = styled("class-a ', target, '")']
expectClassPosition(target, contents, 'tsx')
})

test('escaped single quotes', () => {
test.concurrent('escaped single quotes', () => {
const target = `content:\\'\\'`
const contents = [`export default () => <div className={'block `, target, `'}></div>`]
expectClassPosition(target, contents, 'tsx')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { test, it, expect, describe } from 'vitest'
import dedent from 'ts-dedent'
import { expectClassPosition } from './test'

test('class in ternary operator', () => {
test.concurrent('class in ternary operator', () => {
const target = 'class-a'
const contents = ['<div class:list={ isActive ? \'', target, '\' : inactiveClass }></div>']
expectClassPosition(target, contents, 'astro')
})

test('mixed class assignment formats', () => {
test.concurrent('mixed class assignment formats', () => {
const target = ''
const contents = [dedent`
<div
Expand Down
16 changes: 8 additions & 8 deletions packages/language-service/tests/get-class-position/react.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,51 @@ import { CSSLanguageService } from '../../src'
import createDoc from '../../src/utils/create-doc'
import { expectClassPosition } from './test'

test('empty string with single quote', () => {
test.concurrent('empty string with single quote', () => {
const target = ''
const contents = ['export default () => <div className=\'', target, '\'></div>']
expectClassPosition(target, contents, 'tsx')
})

test('empty string with double quote', () => {
test.concurrent('empty string with double quote', () => {
const target = ''
const contents = ['export default () => <div className="', target, '"></div>']
expectClassPosition(target, contents, 'tsx')
})

test('empty binding', () => {
test.concurrent('empty binding', () => {
const contents = ['export default () => <div className={', '', '}></div>']
const doc = createDoc('tsx', contents.join(''))
const languageService = new CSSLanguageService()
expect(languageService.getClassPosition(doc, { line: 0, character: contents[0].length })).toBeUndefined()
})

test('empty string binding with double quote', () => {
test.concurrent('empty string binding with double quote', () => {
const target = ''
const contents = ['export default () => <div className={"', target, '"}></div>']
expectClassPosition(target, contents, 'tsx')
})

test('empty clsx', () => {
test.concurrent('empty clsx', () => {
const contents = ['export default () => <div className={clsx(', '', ')}></div>']
const doc = createDoc('tsx', contents.join(''))
const languageService = new CSSLanguageService()
expect(languageService.getClassPosition(doc, { line: 0, character: contents[0].length })).toBeUndefined()
})

test('two classes in clsx fn', () => {
test.concurrent('two classes in clsx fn', () => {
const target = 'class-b'
const contents = ['export default () => <div className={clsx("class-a","', target, '")}></div>']
expectClassPosition(target, contents, 'tsx')
})

test('quote in clsx fn', () => {
test.concurrent('quote in clsx fn', () => {
const target = `content:''`
const contents = ['export default () => <div className={clsx("class-a","', target, '")}></div>']
expectClassPosition(target, contents)
})

test('template literal and newlines', () => {
test.concurrent('template literal and newlines', () => {
const target = `class-e`
const contents = ['export default () => <div className={clsx("class-a class-b",`class-c class-d\n', target, '`)}></div>']
expectClassPosition(target, contents)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { test, it, expect, describe } from 'vitest'
import { expectClassPosition } from './test'

describe('var', () => {
test('styles with double quotes', () => {
describe.concurrent('var', () => {
test.concurrent('styles with double quotes', () => {
const target = 'class-b'
const contents = ['const styles = "class-a ', target, '"']
expectClassPosition(target, contents, 'js')
})

test('styles with single quotes', () => {
test.concurrent('styles with single quotes', () => {
const target = 'class-b'
const contents = ['const styles = \'class-a ', target, '\'']
expectClassPosition(target, contents, 'js')
})

test('styles with literals', () => {
test.concurrent('styles with literals', () => {
const target = 'class-b'
const contents = ['const styles = `class-a ', target, '`']
expectClassPosition(target, contents, 'js')
})
})

describe('object', () => {
test('styles with double quotes', () => {
describe.concurrent('object', () => {
test.concurrent('styles with double quotes', () => {
const target = 'class-b'
const contents = ['const config = { styles: "class-a ', target, '" }']
expectClassPosition(target, contents, 'js')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import { test, it, expect, describe } from 'vitest'
import dedent from 'ts-dedent'
import { expectClassPosition } from './test'

test('styled template literal', () => {
test.concurrent('styled template literal', () => {
const target = 'class-b'
const contents = ['const Button = styled.button`class-a ', target, '`']
expectClassPosition(target, contents, 'tsx')
})

test('styled template literal and new lines', () => {
test.concurrent('styled template literal and new lines', () => {
const target = 'class-b'
const contents = [dedent`
const Button = styled
.button\`class-a `, target, '`']
expectClassPosition(target, contents, 'tsx')
})

test('styled invoked', () => {
test.concurrent('styled invoked', () => {
const target = 'class-b'
const contents = ['const Button = styled.button("class-a ', target, '")']
expectClassPosition(target, contents, 'tsx')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, it, expect, describe } from 'vitest'
import { expectClassPosition } from './test'

test('class in ternary operator', () => {
test.concurrent('class in ternary operator', () => {
const target = 'class-a'
const contents = ['<div class={ isActive ? \'', target, '\' : inactiveClass }></div>']
expectClassPosition(target, contents, 'svelte')
Expand Down
16 changes: 8 additions & 8 deletions packages/language-service/tests/get-class-position/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,49 @@ export const expectClassPosition = (target: string, contents: string[], ext: key
return classPosition
}

test('empty class with single quotes', () => {
test.concurrent('empty class with single quotes', () => {
const target = ''
const contents = ['<div class=\'', target, '\'></div>']
expectClassPosition(target, contents)
})

test('empty class with double quotes', () => {
test.concurrent('empty class with double quotes', () => {
const target = ''
const contents = ['<div class="', target, '"></div>']
expectClassPosition(target, contents)
})

test('one class', () => {
test.concurrent('one class', () => {
const target = 'class-a'
const contents = ['<div class="', target, '"></div>']
expectClassPosition(target, contents)
})

test('two classes', () => {
test.concurrent('two classes', () => {
const target = 'class-b'
const contents = ['<div class="class-a ', target, '"></div>']
expectClassPosition(target, contents)
})

test('valid classes', () => {
test.concurrent('valid classes', () => {
const target = 'bg:black'
const contents = ['<div class="class-a ', target, '"></div>']
expectClassPosition(target, contents)
})

test('quote in class', () => {
test.concurrent('quote in class', () => {
const target = `content:''`
const contents = ['<div class="class-a ', target, '"></div>']
expectClassPosition(target, contents)
})

test('group syntax', () => {
test.concurrent('group syntax', () => {
const target = '{abs}'
const contents = ['<div class="class-a ', target, '"></div>']
expectClassPosition(target, contents)
})

test('nested strings and literals', () => {
test.concurrent('nested strings and literals', () => {
const target = `content:\\'\\'`
const contents = [`export default () => <div className={'block `, target, `'}>hello world</div>`]
expectClassPosition(target, contents, 'tsx')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, it, expect, describe } from 'vitest'
import { expectClassPosition } from './test'

test('single quote', () => {
test.concurrent('single quote', () => {
const target = ''
const contents = ['export default () => <div className=\'', target, '\'></div>']
expectClassPosition(target, contents, 'tsx')
Expand Down
10 changes: 5 additions & 5 deletions packages/language-service/tests/get-class-position/vue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ import { test, it, expect, describe } from 'vitest'
import dedent from 'ts-dedent'
import { expectClassPosition } from './test'

test('class in class array', () => {
test.concurrent('class in class array', () => {
const target = 'class-a'
const contents = ['<div :class="[ isActive && `', target, '` ]"></div>']
expectClassPosition(target, contents, 'vue')
})

test('class in object syntax', () => {
test.concurrent('class in object syntax', () => {
const target = 'class-a'
const contents = ['<div :class="{ \'', target, '\': isActive }"></div>']
expectClassPosition(target, contents, 'vue')
})

test('class in ternary operator', () => {
test.concurrent('class in ternary operator', () => {
const target = 'class-a'
const contents = ['<div :class="isActive ? \'', target, '\' : inactiveClass"></div>']
expectClassPosition(target, contents, 'vue')
})

test('class in v-bind', () => {
test.concurrent('class in v-bind', () => {
const target = 'class-a'
const contents = ['<div v-bind:class="{ active: isActive, \'', target, '\': hasError }"></div>']
expectClassPosition(target, contents, 'vue')
})

test('multiple :class assignments', () => {
test.concurrent('multiple :class assignments', () => {
const target = 'a'
const contents = [dedent`
<template>
Expand Down
4 changes: 2 additions & 2 deletions packages/language-service/tests/inspect-syntax.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const inspect = (target: string, settings: Settings = {}) => {
return languageService.inspectSyntax(doc, range?.start as Position)
}

test('text:center', async () => {
test.concurrent('text:center', async () => {
const target = 'text:center'
const hover = inspect(target)
expect(hover?.contents).toEqual({
Expand All @@ -37,7 +37,7 @@ test('text:center', async () => {
})
})

test('hidden', async () => {
test.concurrent('hidden', async () => {
const target = 'hidden'
const hover = inspect(target)
expect(hover?.contents).toEqual({
Expand Down
Loading

0 comments on commit cbb78b3

Please sign in to comment.