Skip to content

Commit 0344c51

Browse files
committed
test: add test case
1 parent f2b5f33 commit 0344c51

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

test/nuxt/components/DateTime.spec.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import DateTime from '~/components/DateTime.vue'
55
// Mock the useRelativeDates composable
66
const mockRelativeDates = shallowRef(false)
77
vi.mock('~/composables/useSettings', () => ({
8-
useRelativeDates: () => mockRelativeDates,
98
useSettings: () => ({
109
settings: ref({ relativeDates: mockRelativeDates.value }),
1110
}),
@@ -128,6 +127,18 @@ describe('DateTime', () => {
128127
})
129128
expect(component.find('time').attributes('title')).toContain(testYear)
130129
})
130+
131+
it('click to toggle relative dates setting', async () => {
132+
const component = await mountSuspended(DateTime, {
133+
props: { datetime: testDate },
134+
})
135+
136+
const button = component.find('button')
137+
button.trigger('click')
138+
expect(mockRelativeDates.value).toBeTruthy()
139+
button.trigger('click')
140+
expect(mockRelativeDates.value).toBeFalsy()
141+
})
131142
})
132143

133144
describe('SSR fallback', () => {

0 commit comments

Comments
 (0)