chore: Refactor tests to use findBy queries for better async handling, update mock implementations, and clean up imports across various test files. Adjust toast utility to use for-of loops for callback execution. Update Vite and Vitest configuration files for consistency.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
|
||||
import compareHosts from '../compareHosts'
|
||||
|
||||
import type { ProxyHost } from '../../api/proxyHosts'
|
||||
|
||||
const hostA: ProxyHost = {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||
|
||||
import {
|
||||
buildCrowdsecExportFilename,
|
||||
promptCrowdsecFilename,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
|
||||
import { calculatePasswordStrength } from '../passwordStrength'
|
||||
|
||||
describe('calculatePasswordStrength', () => {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { vi } from 'vitest'
|
||||
|
||||
import {
|
||||
formatSettingLabel,
|
||||
settingHelpText,
|
||||
settingKeyToField,
|
||||
applyBulkSettingsToHosts,
|
||||
} from '../proxyHostsHelpers'
|
||||
|
||||
import type { ProxyHost } from '../../api/proxyHosts'
|
||||
import { vi } from 'vitest'
|
||||
|
||||
describe('proxyHostsHelpers', () => {
|
||||
describe('formatSettingLabel', () => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { toast, toastCallbacks } from '../toast'
|
||||
|
||||
describe('toast util', () => {
|
||||
|
||||
@@ -12,18 +12,18 @@ export const toastCallbacks = new Set<(toast: Toast) => void>()
|
||||
export const toast = {
|
||||
success: (message: string) => {
|
||||
const id = ++toastId
|
||||
toastCallbacks.forEach(callback => callback({ id, message, type: 'success' }))
|
||||
for (const callback of toastCallbacks) callback({ id, message, type: 'success' })
|
||||
},
|
||||
error: (message: string) => {
|
||||
const id = ++toastId
|
||||
toastCallbacks.forEach(callback => callback({ id, message, type: 'error' }))
|
||||
for (const callback of toastCallbacks) callback({ id, message, type: 'error' })
|
||||
},
|
||||
info: (message: string) => {
|
||||
const id = ++toastId
|
||||
toastCallbacks.forEach(callback => callback({ id, message, type: 'info' }))
|
||||
for (const callback of toastCallbacks) callback({ id, message, type: 'info' })
|
||||
},
|
||||
warning: (message: string) => {
|
||||
const id = ++toastId
|
||||
toastCallbacks.forEach(callback => callback({ id, message, type: 'warning' }))
|
||||
for (const callback of toastCallbacks) callback({ id, message, type: 'warning' })
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user