1
0

feat: replace jest with vitest

This commit is contained in:
Dominik Pschenitschni
2022-01-01 14:24:06 +01:00
parent bc4ea82639
commit 8114012997
14 changed files with 323 additions and 1406 deletions

View File

@ -1,3 +1,5 @@
import {it, expect} from 'vitest'
import {calculateItemPosition} from './calculateItemPosition'
it('should calculate the task position', () => {

View File

@ -1,3 +1,5 @@
import {describe, it, expect} from 'vitest'
import {findCheckboxesInText, getChecklistStatistics} from './checklistFromText'
describe('Find checklists in text', () => {

View File

@ -1,3 +1,5 @@
import {test, expect} from 'vitest'
import {colorFromHex} from './colorFromHex'
test('hex', () => {

View File

@ -1,3 +1,5 @@
import {test, expect} from 'vitest'
import {colorIsDark} from './colorIsDark'
test('dark color', () => {

View File

@ -1,3 +1,5 @@
import {describe, it, expect} from 'vitest'
import {filterLabelsByQuery} from './labels'
import {createNewIndexer} from '../indexes'

View File

@ -1,3 +1,5 @@
import {test, expect} from 'vitest'
import {calculateDayInterval} from './calculateDayInterval'
const days = {

View File

@ -1,3 +1,5 @@
import {test, expect} from 'vitest'
import {calculateNearestHours} from './calculateNearestHours'
test('5:00', () => {

View File

@ -1,3 +1,5 @@
import {test, expect} from 'vitest'
import {createDateFromString} from './createDateFromString'
test('YYYY-MM-DD HH:MM', () => {

View File

@ -1,14 +1,15 @@
import {test, expect, fn} from 'vitest'
import {getHistory, removeListFromHistory, saveListToHistory} from './listHistory'
test('return an empty history when none was saved', () => {
Storage.prototype.getItem = jest.fn(() => null)
Storage.prototype.getItem = fn(() => null)
const h = getHistory()
expect(h).toStrictEqual([])
})
test('return a saved history', () => {
const saved = [{id: 1}, {id: 2}]
Storage.prototype.getItem = jest.fn(() => JSON.stringify(saved))
Storage.prototype.getItem = fn(() => JSON.stringify(saved))
const h = getHistory()
expect(h).toStrictEqual(saved)
@ -16,8 +17,8 @@ test('return a saved history', () => {
test('store list in history', () => {
let saved = {}
Storage.prototype.getItem = jest.fn(() => null)
Storage.prototype.setItem = jest.fn((key, lists) => {
Storage.prototype.getItem = fn(() => null)
Storage.prototype.setItem = fn((key, lists) => {
saved = lists
})
@ -27,8 +28,8 @@ test('store list in history', () => {
test('store only the last 5 lists in history', () => {
let saved: string | null = null
Storage.prototype.getItem = jest.fn(() => saved)
Storage.prototype.setItem = jest.fn((key: string, lists: string) => {
Storage.prototype.getItem = fn(() => saved)
Storage.prototype.setItem = fn((key: string, lists: string) => {
saved = lists
})
@ -43,8 +44,8 @@ test('store only the last 5 lists in history', () => {
test('don\'t store the same list twice', () => {
let saved: string | null = null
Storage.prototype.getItem = jest.fn(() => saved)
Storage.prototype.setItem = jest.fn((key: string, lists: string) => {
Storage.prototype.getItem = fn(() => saved)
Storage.prototype.setItem = fn((key: string, lists: string) => {
saved = lists
})
@ -55,8 +56,8 @@ test('don\'t store the same list twice', () => {
test('move a list to the beginning when storing it multiple times', () => {
let saved: string | null = null
Storage.prototype.getItem = jest.fn(() => saved)
Storage.prototype.setItem = jest.fn((key: string, lists: string) => {
Storage.prototype.getItem = fn(() => saved)
Storage.prototype.setItem = fn((key: string, lists: string) => {
saved = lists
})
@ -68,11 +69,11 @@ test('move a list to the beginning when storing it multiple times', () => {
test('remove list from history', () => {
let saved: string | null = '[{"id": 1}]'
Storage.prototype.getItem = jest.fn(() => null)
Storage.prototype.setItem = jest.fn((key: string, lists: string) => {
Storage.prototype.getItem = fn(() => null)
Storage.prototype.setItem = fn((key: string, lists: string) => {
saved = lists
})
Storage.prototype.removeItem = jest.fn((key: string) => {
Storage.prototype.removeItem = fn((key: string) => {
saved = null
})

View File

@ -1,3 +1,5 @@
import {describe, it, expect} from 'vitest'
import {parseTaskText} from './parseTaskText'
import {getDateFromText, getDateFromTextIn} from '../helpers/time/parseDate'
import {calculateDayInterval} from '../helpers/time/calculateDayInterval'