-
-
Notifications
You must be signed in to change notification settings - Fork 424
Expand file tree
/
Copy pathDateTimeButton.spec.ts
More file actions
36 lines (30 loc) · 1.05 KB
/
DateTimeButton.spec.ts
File metadata and controls
36 lines (30 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { mountSuspended } from '@nuxt/test-utils/runtime'
import { describe, it, expect, vi, beforeEach } from 'vitest'
import DateTimeButton from '~/components/DateTimeButton.vue'
// Mock the useRelativeDates composable
const mockRelativeDates = shallowRef(false)
vi.mock('~/composables/useSettings', () => ({
useRelativeDates: () => ({
relativeDates: mockRelativeDates,
}),
useSettings: () => ({
settings: ref({ relativeDates: mockRelativeDates.value }),
}),
useAccentColor: () => ({}),
}))
describe('DateTimeButton', () => {
const testDate = '2024-01-15T12:00:00.000Z'
beforeEach(() => {
mockRelativeDates.value = false
})
it('clicking button to toggle the relative dates settings', async () => {
const component = await mountSuspended(DateTimeButton, {
props: { datetime: testDate },
})
const button = component.find('button')
await button.trigger('click')
expect(button.attributes('aria-pressed')).toBe('true')
await button.trigger('click')
expect(button.attributes('aria-pressed')).toBe('false')
})
})