diff --git a/tests/helpers.js b/tests/helpers.ts similarity index 63% rename from tests/helpers.js rename to tests/helpers.ts index dde133f..c35a623 100755 --- a/tests/helpers.js +++ b/tests/helpers.ts @@ -1,14 +1,16 @@ -import { mount, shallowMount } from '@vue/test-utils' +import { mount, VueWrapper } from '@vue/test-utils' import VueSelect from '@/components/Select.vue' +type WrappedVueSelect = VueWrapper> + /** * Trigger a submit event on the search * input with a provided search text. - * - * @param Wrapper {Wrapper} - * @param searchText */ -export const searchSubmit = async (Wrapper, searchText = undefined) => { +export const searchSubmit = async ( + Wrapper: WrappedVueSelect, + searchText?: string +) => { await Wrapper.get('input').trigger('focus') if (searchText) { @@ -22,18 +24,18 @@ export const searchSubmit = async (Wrapper, searchText = undefined) => { /** * Focus the search input */ -export const searchFocus = async (Wrapper) => { +export const searchFocus = async (Wrapper: WrappedVueSelect) => { await Wrapper.get('input').trigger('focus') await Wrapper.vm.$nextTick() } /** * Focus the input, enter some search text, hit return. - * @param Wrapper {Wrapper} - * @param searchText - * @return {Promise} */ -export const selectTag = async (Wrapper, searchText) => { +export const selectTag = async ( + Wrapper: WrappedVueSelect, + searchText: string +) => { Wrapper.vm.$refs.search.focus() await Wrapper.vm.$nextTick() @@ -46,20 +48,15 @@ export const selectTag = async (Wrapper, searchText) => { /** * Create a new VueSelect instance with * a provided set of props. - * @param props - * @returns {Wrapper} */ -export const selectWithProps = (props = {}) => { +export const selectWithProps = (props = {}): WrappedVueSelect => { return mount(VueSelect, { props }) } /** * Returns a Wrapper with a v-select component. - * @param props - * @param options - * @return {Wrapper} */ -export const mountDefault = (props = {}, options = {}) => { +export const mountDefault = (props = {}, options = {}): WrappedVueSelect => { return mount(VueSelect, { props: { options: ['one', 'two', 'three'], diff --git a/tests/unit/Accessibility.spec.js b/tests/unit/Accessibility.spec.js index a836dcb..fbd6caa 100644 --- a/tests/unit/Accessibility.spec.js +++ b/tests/unit/Accessibility.spec.js @@ -1,5 +1,5 @@ import { it, describe, expect } from 'vitest' -import { mountDefault } from '@tests/helpers.js' +import { mountDefault } from '@tests/helpers.ts' describe('Search Slot Scope', () => { /** diff --git a/tests/unit/Ajax.spec.js b/tests/unit/Ajax.spec.js index 410fe86..5df293f 100755 --- a/tests/unit/Ajax.spec.js +++ b/tests/unit/Ajax.spec.js @@ -1,5 +1,5 @@ import { it, describe, expect } from 'vitest' -import { selectWithProps } from '@tests/helpers.js' +import { selectWithProps } from '@tests/helpers.ts' import { shallowMount } from '@vue/test-utils' import vSelect from '@/components/Select.vue' diff --git a/tests/unit/Autoscroll.spec.js b/tests/unit/Autoscroll.spec.js index 502b124..fcc4828 100644 --- a/tests/unit/Autoscroll.spec.js +++ b/tests/unit/Autoscroll.spec.js @@ -1,6 +1,6 @@ import { it, describe, expect, vi, afterEach } from 'vitest' import pointerScroll from '@/mixins/pointerScroll.js' -import { mountDefault } from '@tests/helpers.js' +import { mountDefault } from '@tests/helpers.ts' describe('Automatic Scrolling', () => { let spy diff --git a/tests/unit/Components.spec.js b/tests/unit/Components.spec.js index 5605d1c..377552f 100644 --- a/tests/unit/Components.spec.js +++ b/tests/unit/Components.spec.js @@ -1,6 +1,6 @@ import { it, describe, expect } from 'vitest' import { defineComponent } from 'vue' -import { selectWithProps } from '@tests/helpers.js' +import { selectWithProps } from '@tests/helpers.ts' describe('Components API', () => { it('swap the Deselect component', () => { diff --git a/tests/unit/CreateOption.spec.js b/tests/unit/CreateOption.spec.js index 7c4cf34..e16fc77 100644 --- a/tests/unit/CreateOption.spec.js +++ b/tests/unit/CreateOption.spec.js @@ -1,5 +1,5 @@ import { it, describe, expect } from 'vitest' -import { selectTag, selectWithProps } from '@tests/helpers.js' +import { selectTag, selectWithProps } from '@tests/helpers.ts' describe('CreateOption When Tagging Is Enabled', () => { it('can select the current search text as a string', async () => { diff --git a/tests/unit/Deselecting.spec.js b/tests/unit/Deselecting.spec.js index f39abe5..3aef8d4 100755 --- a/tests/unit/Deselecting.spec.js +++ b/tests/unit/Deselecting.spec.js @@ -1,5 +1,5 @@ import { it, describe, expect, vi } from 'vitest' -import { mountDefault, selectWithProps } from '@tests/helpers.js' +import { mountDefault, selectWithProps } from '@tests/helpers.ts' describe('Removing values', () => { it('can remove the given tag when its close icon is clicked', async () => { diff --git a/tests/unit/Dropdown.spec.js b/tests/unit/Dropdown.spec.js index 223be11..315394a 100755 --- a/tests/unit/Dropdown.spec.js +++ b/tests/unit/Dropdown.spec.js @@ -1,7 +1,8 @@ import { it, describe, expect, vi, afterEach } from 'vitest' -import { selectWithProps } from '@tests/helpers.js' +import { selectWithProps } from '@tests/helpers.ts' import OpenIndicator from '@/components/OpenIndicator.vue' import VueSelect from '@/components/Select.vue' +import DropdownMenu from '@/components/DropdownMenu.vue' const preventDefault = vi.fn() diff --git a/tests/unit/Keydown.spec.js b/tests/unit/Keydown.spec.js index 753804b..c076f13 100644 --- a/tests/unit/Keydown.spec.js +++ b/tests/unit/Keydown.spec.js @@ -1,6 +1,6 @@ import { it, describe, expect, vi, afterEach } from 'vitest' import typeAheadPointer from '@/mixins/typeAheadPointer.js' -import { mountDefault } from '@tests/helpers.js' +import { mountDefault } from '@tests/helpers.ts' describe('Custom Keydown Handlers', () => { let spy diff --git a/tests/unit/Labels.spec.js b/tests/unit/Labels.spec.js index 91b20cd..4f900f1 100755 --- a/tests/unit/Labels.spec.js +++ b/tests/unit/Labels.spec.js @@ -1,7 +1,7 @@ import { it, describe, expect, vi } from 'vitest' import { mount } from '@vue/test-utils' import VueSelect from '@/components/Select.vue' -import { selectWithProps } from '@tests/helpers.js' +import { selectWithProps } from '@tests/helpers.ts' describe('Labels', () => { it('can generate labels using a custom label key', () => { diff --git a/tests/unit/ReactiveOptions.spec.js b/tests/unit/ReactiveOptions.spec.js index 15e572c..5770669 100755 --- a/tests/unit/ReactiveOptions.spec.js +++ b/tests/unit/ReactiveOptions.spec.js @@ -1,7 +1,7 @@ import { it, describe, expect, vi, afterEach } from 'vitest' import { shallowMount } from '@vue/test-utils' import VueSelect from '@/components/Select.vue' -import { mountDefault } from '@tests/helpers.js' +import { mountDefault } from '@tests/helpers.ts' describe('Reset on options change', () => { it('should not reset the selected value by default when the options property changes', async () => { diff --git a/tests/unit/Reduce.spec.js b/tests/unit/Reduce.spec.js index 695809e..b21484e 100755 --- a/tests/unit/Reduce.spec.js +++ b/tests/unit/Reduce.spec.js @@ -1,7 +1,7 @@ import { it, describe, expect } from 'vitest' import { mount, shallowMount } from '@vue/test-utils' import VueSelect from '@/components/Select.vue' -import { mountDefault } from '@tests/helpers.js' +import { mountDefault } from '@tests/helpers.ts' describe('When reduce prop is defined', () => { it('determines when a reducer has been supplied', async () => { diff --git a/tests/unit/Selectable.spec.js b/tests/unit/Selectable.spec.js index 24ab8a8..d3dfaa1 100644 --- a/tests/unit/Selectable.spec.js +++ b/tests/unit/Selectable.spec.js @@ -1,5 +1,5 @@ import { it, describe, expect } from 'vitest' -import { searchSubmit, selectWithProps } from '@tests/helpers.js' +import { searchSubmit, selectWithProps } from '@tests/helpers.ts' describe('Selectable prop', () => { it('should select selectable option if clicked', async () => { diff --git a/tests/unit/Selecting.spec.js b/tests/unit/Selecting.spec.js index 328fe6b..72c4ba6 100755 --- a/tests/unit/Selecting.spec.js +++ b/tests/unit/Selecting.spec.js @@ -2,7 +2,7 @@ import { it, describe, expect, vi, beforeEach, afterEach } from 'vitest' import { mount } from '@vue/test-utils' import VueSelect from '@/components/Select.vue' import typeAheadPointer from '@/mixins/typeAheadPointer.js' -import { mountDefault } from '@tests/helpers.js' +import { mountDefault } from '@tests/helpers.ts' describe('VS - Selecting Values', () => { let defaultProps diff --git a/tests/unit/Slots.spec.js b/tests/unit/Slots.spec.js index 317de50..16a360e 100644 --- a/tests/unit/Slots.spec.js +++ b/tests/unit/Slots.spec.js @@ -1,6 +1,6 @@ import { it, test, describe, expect, vi } from 'vitest' import { h } from 'vue' -import { mountDefault } from '@tests/helpers.js' +import { mountDefault } from '@tests/helpers.ts' describe('Scoped Slots', () => { it('receives an option object to the selected-option-container slot', () => { diff --git a/tests/unit/Tagging.spec.js b/tests/unit/Tagging.spec.js index b09577b..56cff4f 100755 --- a/tests/unit/Tagging.spec.js +++ b/tests/unit/Tagging.spec.js @@ -4,7 +4,7 @@ import { searchSubmit, selectTag, selectWithProps, -} from '@tests/helpers.js' +} from '@tests/helpers.ts' import VueSelect from '@/components/Select.vue' describe('When Tagging Is Enabled', () => { diff --git a/tests/unit/TypeAhead.spec.js b/tests/unit/TypeAhead.spec.js index a960704..3763df4 100755 --- a/tests/unit/TypeAhead.spec.js +++ b/tests/unit/TypeAhead.spec.js @@ -1,7 +1,7 @@ import { it, describe, expect } from 'vitest' import { shallowMount } from '@vue/test-utils' import VueSelect from '@/components/Select.vue' -import { mountDefault } from '@tests/helpers.js' +import { mountDefault } from '@tests/helpers.ts' describe('Moving the Typeahead Pointer', () => { it('should set the pointer to zero when the filteredOptions watcher is called', async () => {