Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript Rollout Tier 8 - TimepickerMixin #372

Merged
merged 2 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { defineComponent } from 'vue'
import { shallowMount } from '@vue/test-utils'
import type { VueWrapper } from '@vue/test-utils'
import TimepickerMixin from '@utils/TimepickerMixin'

const AM = 'AM'
const PM = 'PM'
let wrapper

const component = defineComponent({
mixins: [TimepickerMixin],
template: '<div class="b-component"></div>'
})

let wrapper: VueWrapper<InstanceType<typeof component>>

describe('TimepickerMixin', () => {
HTMLElement.prototype.insertAdjacentElement = jest.fn()
HTMLElement.prototype.insertAdjacentElement = vi.fn()
beforeEach(() => {
const component = {
template: '<div class="b-component"></div>',
mixins: [TimepickerMixin]
}
wrapper = shallowMount(component, {
attachTo: document.body
})
Expand All @@ -30,8 +35,8 @@ describe('TimepickerMixin', () => {
})

it('should call updateDateSelected on onSecondsChange', async () => {
wrapper.vm.updateDateSelected = jest.fn()
wrapper.vm.onSecondsChange()
wrapper.vm.updateDateSelected = vi.fn()
wrapper.vm.onSecondsChange('0')
await wrapper.vm.$nextTick()
expect(wrapper.vm.updateDateSelected).toHaveBeenCalledTimes(1)
})
Expand All @@ -55,14 +60,14 @@ describe('TimepickerMixin', () => {
})

it('should call onFocus on handleOnFocus', async () => {
wrapper.vm.onFocus = jest.fn()
wrapper.vm.onFocus = vi.fn()
wrapper.vm.handleOnFocus()
await wrapper.vm.$nextTick()
expect(wrapper.vm.onFocus).toHaveBeenCalledTimes(1)
})

it('should call toggle on close', async () => {
wrapper.vm.toggle = jest.fn()
wrapper.vm.toggle = vi.fn()
wrapper.vm.close()
await wrapper.vm.$nextTick()
expect(wrapper.vm.toggle).toHaveBeenCalledTimes(1)
Expand Down
Loading
Loading