Skip to content

Commit

Permalink
Core - Update config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smastrom committed Apr 13, 2024
1 parent 791e34f commit 7389342
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
14 changes: 9 additions & 5 deletions tests/config/update-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import {
DEFAULT_NOTIFICATION_OPTIONS as defaultNot,
} from '@/core/constants'

import type { UseNotivueReturn, NotivueConfig, NotivueConfigRequired } from 'notivue'
import { ref } from 'vue'

import type { NotivueConfig, NotivueConfigRequired, ConfigSlice } from 'notivue'

type ConfigPairs<K extends keyof NotivueConfig> = [K, NotivueConfig[K]]

describe('Update method', () => {
const isRunning = ref(true)

test('Should update primitive properties', () => {
const newConf: ConfigPairs<keyof NotivueConfig>[] = [
['pauseOnTouch', false],
Expand All @@ -22,7 +26,7 @@ describe('Update method', () => {
['limit', Math.random() * 100],
]

const config = createConfig({}) as UseNotivueReturn
const config = createConfig({}, isRunning) as ConfigSlice

for (const [key, value] of newConf) {
expect(config[key].value).not.toBe(value)
Expand All @@ -37,7 +41,7 @@ describe('Update method', () => {
test('Animations', () => {
const animations = { enter: 'Vitest_Enter', leave: 'Vitest_Leave' }

const config = createConfig({})
const config = createConfig({}, isRunning) as ConfigSlice

config.update({ animations })

Expand All @@ -59,7 +63,7 @@ describe('Update method', () => {
'promise-reject': { duration: Math.random() * 100 },
}

const config = createConfig({}) as UseNotivueReturn
const config = createConfig({}, isRunning) as ConfigSlice

config.update({ notifications: newConf })

Expand Down Expand Up @@ -89,7 +93,7 @@ describe('Update method', () => {
},
}

const c = createConfig(userConf) as UseNotivueReturn
const c = createConfig(userConf, isRunning) as ConfigSlice

let prevConf = {} as NotivueConfigRequired

Expand Down
10 changes: 5 additions & 5 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
"notivue": "workspace:*"
},
"devDependencies": {
"@types/node": "^20.12.5",
"@types/node": "^20.12.7",
"@vitejs/plugin-vue": "^5.0.4",
"@vue/test-utils": "^2.4.5",
"axe-core": "^4.9.0",
"cypress": "^13.7.2",
"cypress": "^13.7.3",
"cypress-axe": "^1.5.0",
"cypress-real-events": "^1.12.0",
"typescript": "^5.4.4",
"typescript": "^5.4.5",
"vite": "^5.2.8",
"vitest": "^1.4.0",
"vitest": "^1.5.0",
"vue": "^3.4.21",
"vue-tsc": "^2.0.10"
"vue-tsc": "^2.0.13"
}
}

0 comments on commit 7389342

Please sign in to comment.