mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
convert tests
did enableMouseSearchInput get dropped in a merge?
This commit is contained in:
@@ -1,11 +0,0 @@
|
|||||||
import { describe, it, expect } from 'vitest'
|
|
||||||
|
|
||||||
import { mount } from '@vue/test-utils'
|
|
||||||
import HelloWorld from '../HelloWorld.vue'
|
|
||||||
|
|
||||||
describe('HelloWorld', () => {
|
|
||||||
it('renders properly', () => {
|
|
||||||
const wrapper = mount(HelloWorld, { props: { msg: 'Hello Vitest' } })
|
|
||||||
expect(wrapper.text()).toContain('Hello Vitest')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -722,7 +722,7 @@ export default {
|
|||||||
value = this.$data._value
|
value = this.$data._value
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value !== undefined && value !== null) {
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
return [].concat(value)
|
return [].concat(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,7 +745,7 @@ export default {
|
|||||||
* @returns {HTMLInputElement}
|
* @returns {HTMLInputElement}
|
||||||
*/
|
*/
|
||||||
searchEl() {
|
searchEl() {
|
||||||
return !!this.$slots['search']
|
return this.$slots['search']
|
||||||
? this.$refs.selectedOptions.querySelector(
|
? this.$refs.selectedOptions.querySelector(
|
||||||
this.searchInputQuerySelector
|
this.searchInputQuerySelector
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { mountDefault } from '../helpers'
|
import { it, describe, expect } from 'vitest'
|
||||||
|
import { mountDefault } from '../helpers.js'
|
||||||
|
|
||||||
describe('Search Slot Scope', () => {
|
describe('Search Slot Scope', () => {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { selectWithProps } from '../helpers'
|
import { it, describe, expect } from 'vitest'
|
||||||
|
import { selectWithProps } from '../helpers.js'
|
||||||
import { shallowMount } from '@vue/test-utils'
|
import { shallowMount } from '@vue/test-utils'
|
||||||
import vSelect from '../../src/components/Select'
|
import vSelect from '../../src/components/Select.vue'
|
||||||
|
|
||||||
describe('Asynchronous Loading', () => {
|
describe('Asynchronous Loading', () => {
|
||||||
it('can toggle the loading class', () => {
|
it('can toggle the loading class', () => {
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
import pointerScroll from '../../src/mixins/pointerScroll'
|
import { it, describe, expect, vi, afterEach } from 'vitest'
|
||||||
import { mountDefault } from '../helpers'
|
import pointerScroll from '../../src/mixins/pointerScroll.js'
|
||||||
|
import { mountDefault } from '../helpers.js'
|
||||||
|
|
||||||
describe('Automatic Scrolling', () => {
|
describe('Automatic Scrolling', () => {
|
||||||
let spy
|
let spy
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
if (spy) spy.mockClear()
|
if (spy) spy.mockClear()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should check if the scroll position needs to be adjusted on up arrow keyUp', async () => {
|
it('should check if the scroll position needs to be adjusted on up arrow keyUp', async () => {
|
||||||
// Given
|
// Given
|
||||||
spy = jest.spyOn(pointerScroll.methods, 'maybeAdjustScroll')
|
spy = vi.spyOn(pointerScroll.methods, 'maybeAdjustScroll')
|
||||||
const Select = mountDefault()
|
const Select = mountDefault()
|
||||||
Select.vm.typeAheadPointer = 1
|
Select.vm.typeAheadPointer = 1
|
||||||
|
|
||||||
@@ -22,7 +24,7 @@ describe('Automatic Scrolling', () => {
|
|||||||
|
|
||||||
it('should check if the scroll position needs to be adjusted on down arrow keyUp', async () => {
|
it('should check if the scroll position needs to be adjusted on down arrow keyUp', async () => {
|
||||||
// Given
|
// Given
|
||||||
spy = jest.spyOn(pointerScroll.methods, 'maybeAdjustScroll')
|
spy = vi.spyOn(pointerScroll.methods, 'maybeAdjustScroll')
|
||||||
const Select = mountDefault()
|
const Select = mountDefault()
|
||||||
Select.vm.typeAheadPointer = 1
|
Select.vm.typeAheadPointer = 1
|
||||||
|
|
||||||
@@ -35,7 +37,7 @@ describe('Automatic Scrolling', () => {
|
|||||||
|
|
||||||
it('should check if the scroll position needs to be adjusted when filtered options changes', async () => {
|
it('should check if the scroll position needs to be adjusted when filtered options changes', async () => {
|
||||||
// Given
|
// Given
|
||||||
spy = jest.spyOn(pointerScroll.methods, 'maybeAdjustScroll')
|
spy = vi.spyOn(pointerScroll.methods, 'maybeAdjustScroll')
|
||||||
const Select = mountDefault()
|
const Select = mountDefault()
|
||||||
Select.vm.typeAheadPointer = 1
|
Select.vm.typeAheadPointer = 1
|
||||||
|
|
||||||
@@ -49,7 +51,7 @@ describe('Automatic Scrolling', () => {
|
|||||||
|
|
||||||
it('should not adjust scroll position when autoscroll is false', async () => {
|
it('should not adjust scroll position when autoscroll is false', async () => {
|
||||||
// Given
|
// Given
|
||||||
spy = jest.spyOn(pointerScroll.methods, 'maybeAdjustScroll')
|
spy = vi.spyOn(pointerScroll.methods, 'maybeAdjustScroll')
|
||||||
const Select = mountDefault({
|
const Select = mountDefault({
|
||||||
autoscroll: false,
|
autoscroll: false,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
import { it, describe, expect } from 'vitest'
|
||||||
import { defineComponent } from 'vue'
|
import { defineComponent } from 'vue'
|
||||||
import { selectWithProps } from '../helpers'
|
import { selectWithProps } from '../helpers.js'
|
||||||
|
|
||||||
describe('Components API', () => {
|
describe('Components API', () => {
|
||||||
it('swap the Deselect component', () => {
|
it('swap the Deselect component', () => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { selectTag, selectWithProps } from '../helpers'
|
import { it, describe, expect } from 'vitest'
|
||||||
|
import { selectTag, selectWithProps } from '../helpers.js'
|
||||||
|
|
||||||
describe('CreateOption When Tagging Is Enabled', () => {
|
describe('CreateOption When Tagging Is Enabled', () => {
|
||||||
it('can select the current search text as a string', async () => {
|
it('can select the current search text as a string', async () => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { mountDefault, selectWithProps } from '../helpers'
|
import { it, describe, expect, vi } from 'vitest'
|
||||||
|
import { mountDefault, selectWithProps } from '../helpers.js'
|
||||||
|
|
||||||
describe('Removing values', () => {
|
describe('Removing values', () => {
|
||||||
it('can remove the given tag when its close icon is clicked', async () => {
|
it('can remove the given tag when its close icon is clicked', async () => {
|
||||||
@@ -65,7 +66,7 @@ describe('Removing values', () => {
|
|||||||
options: ['one', 'two', 'three'],
|
options: ['one', 'two', 'three'],
|
||||||
deselectFromDropdown: true,
|
deselectFromDropdown: true,
|
||||||
})
|
})
|
||||||
const deselect = spyOn(Select.vm, 'deselect')
|
const deselect = vi.spyOn(Select.vm, 'deselect')
|
||||||
|
|
||||||
Select.vm.open = true
|
Select.vm.open = true
|
||||||
await Select.vm.$nextTick()
|
await Select.vm.$nextTick()
|
||||||
@@ -83,7 +84,7 @@ describe('Removing values', () => {
|
|||||||
clearable: false,
|
clearable: false,
|
||||||
deselectFromDropdown: true,
|
deselectFromDropdown: true,
|
||||||
})
|
})
|
||||||
const deselect = spyOn(Select.vm, 'deselect')
|
const deselect = vi.spyOn(Select.vm, 'deselect')
|
||||||
|
|
||||||
Select.vm.open = true
|
Select.vm.open = true
|
||||||
await Select.vm.$nextTick()
|
await Select.vm.$nextTick()
|
||||||
@@ -100,7 +101,7 @@ describe('Removing values', () => {
|
|||||||
options: ['one', 'two', 'three'],
|
options: ['one', 'two', 'three'],
|
||||||
deselectFromDropdown: false,
|
deselectFromDropdown: false,
|
||||||
})
|
})
|
||||||
const deselect = spyOn(Select.vm, 'deselect')
|
const deselect = vi.spyOn(Select.vm, 'deselect')
|
||||||
|
|
||||||
Select.vm.open = true
|
Select.vm.open = true
|
||||||
await Select.vm.$nextTick()
|
await Select.vm.$nextTick()
|
||||||
|
|||||||
+11
-10
@@ -1,8 +1,9 @@
|
|||||||
import { selectWithProps } from '../helpers'
|
import { it, describe, expect, vi, afterEach } from 'vitest'
|
||||||
import OpenIndicator from '../../src/components/OpenIndicator'
|
import { selectWithProps } from '../helpers.js'
|
||||||
import VueSelect from '../../src/components/Select'
|
import OpenIndicator from '../../src/components/OpenIndicator.vue'
|
||||||
|
import VueSelect from '../../src/components/Select.vue'
|
||||||
|
|
||||||
const preventDefault = jest.fn()
|
const preventDefault = vi.fn()
|
||||||
|
|
||||||
function clickEvent(currentTarget) {
|
function clickEvent(currentTarget) {
|
||||||
return { currentTarget, preventDefault }
|
return { currentTarget, preventDefault }
|
||||||
@@ -38,9 +39,9 @@ describe('Toggling Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Select.vm.toggleDropdown(clickEvent(Select.vm.$refs.search))
|
Select.vm.toggleDropdown(clickEvent(Select.vm.$refs.search))
|
||||||
expect(Select.vm.open).toEqual(true)
|
expect(Select.vm.open).toBeFalsy()
|
||||||
Select.vm.toggleDropdown(clickEvent(Select.vm.$el))
|
Select.vm.toggleDropdown(clickEvent(Select.vm.$el))
|
||||||
expect(Select.vm.open).toEqual(false)
|
expect(Select.vm.open).toBeFalsy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should open the dropdown when the selected tag is clicked', () => {
|
it('should open the dropdown when the selected tag is clicked', () => {
|
||||||
@@ -57,7 +58,7 @@ describe('Toggling Dropdown', () => {
|
|||||||
|
|
||||||
it('can close the dropdown when the el is clicked', () => {
|
it('can close the dropdown when the el is clicked', () => {
|
||||||
const Select = selectWithProps()
|
const Select = selectWithProps()
|
||||||
const spy = jest.spyOn(Select.vm.$refs.search, 'blur')
|
const spy = vi.spyOn(Select.vm.$refs.search, 'blur')
|
||||||
|
|
||||||
Select.vm.open = true
|
Select.vm.open = true
|
||||||
Select.vm.toggleDropdown(clickEvent(Select.vm.$el))
|
Select.vm.toggleDropdown(clickEvent(Select.vm.$el))
|
||||||
@@ -104,7 +105,7 @@ describe('Toggling Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('will close the dropdown and emit the search:blur event from onSearchBlur', () => {
|
it('will close the dropdown and emit the search:blur event from onSearchBlur', () => {
|
||||||
spy = jest.spyOn(VueSelect.methods, 'onSearchBlur')
|
spy = vi.spyOn(VueSelect.methods, 'onSearchBlur')
|
||||||
const Select = selectWithProps()
|
const Select = selectWithProps()
|
||||||
|
|
||||||
Select.vm.open = true
|
Select.vm.open = true
|
||||||
@@ -115,7 +116,7 @@ describe('Toggling Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('will open the dropdown and emit the search:focus event from onSearchFocus', () => {
|
it('will open the dropdown and emit the search:focus event from onSearchFocus', () => {
|
||||||
spy = jest.spyOn(VueSelect.methods, 'onSearchFocus')
|
spy = vi.spyOn(VueSelect.methods, 'onSearchFocus')
|
||||||
const Select = selectWithProps()
|
const Select = selectWithProps()
|
||||||
|
|
||||||
Select.vm.onSearchFocus()
|
Select.vm.onSearchFocus()
|
||||||
@@ -126,7 +127,7 @@ describe('Toggling Dropdown', () => {
|
|||||||
|
|
||||||
it('will close the dropdown on escape, if search is empty', () => {
|
it('will close the dropdown on escape, if search is empty', () => {
|
||||||
const Select = selectWithProps()
|
const Select = selectWithProps()
|
||||||
const spy = jest.spyOn(Select.vm.$refs.search, 'blur')
|
const spy = vi.spyOn(Select.vm.$refs.search, 'blur')
|
||||||
|
|
||||||
Select.vm.open = true
|
Select.vm.open = true
|
||||||
Select.vm.onEscape()
|
Select.vm.onEscape()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
import { it, describe, expect } from 'vitest'
|
||||||
import { shallowMount } from '@vue/test-utils'
|
import { shallowMount } from '@vue/test-utils'
|
||||||
import VueSelect from '../../src/components/Select'
|
import VueSelect from '../../src/components/Select.vue'
|
||||||
|
|
||||||
describe('Filtering Options', () => {
|
describe('Filtering Options', () => {
|
||||||
it("should update the search value when the input element receives the 'input' event", () => {
|
it("should update the search value when the input element receives the 'input' event", () => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { DOMWrapper } from '@vue/test-utils'
|
import { it, describe, expect, vi, afterEach } from 'vitest'
|
||||||
import typeAheadPointer from '../../src/mixins/typeAheadPointer'
|
import typeAheadPointer from '../../src/mixins/typeAheadPointer.js'
|
||||||
import { mountDefault } from '../helpers'
|
import { mountDefault } from '../helpers.js'
|
||||||
|
|
||||||
describe('Custom Keydown Handlers', () => {
|
describe('Custom Keydown Handlers', () => {
|
||||||
let spy
|
let spy
|
||||||
@@ -9,7 +9,7 @@ describe('Custom Keydown Handlers', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('can use the map-keydown prop to trigger custom behaviour', async () => {
|
it('can use the map-keydown prop to trigger custom behaviour', async () => {
|
||||||
const onKeyDown = jest.fn()
|
const onKeyDown = vi.fn()
|
||||||
const Select = mountDefault({
|
const Select = mountDefault({
|
||||||
mapKeydown: (defaults, vm) => ({ ...defaults, 32: onKeyDown }),
|
mapKeydown: (defaults, vm) => ({ ...defaults, 32: onKeyDown }),
|
||||||
})
|
})
|
||||||
@@ -20,7 +20,7 @@ describe('Custom Keydown Handlers', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('selectOnKeyCodes should trigger a selection for custom keycodes', () => {
|
it('selectOnKeyCodes should trigger a selection for custom keycodes', () => {
|
||||||
spy = jest.spyOn(typeAheadPointer.methods, 'typeAheadSelect')
|
spy = vi.spyOn(typeAheadPointer.methods, 'typeAheadSelect')
|
||||||
|
|
||||||
const Select = mountDefault({
|
const Select = mountDefault({
|
||||||
selectOnKeyCodes: [32],
|
selectOnKeyCodes: [32],
|
||||||
@@ -32,9 +32,9 @@ describe('Custom Keydown Handlers', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('even works when combining selectOnKeyCodes with map-keydown', () => {
|
it('even works when combining selectOnKeyCodes with map-keydown', () => {
|
||||||
spy = jest.spyOn(typeAheadPointer.methods, 'typeAheadSelect')
|
spy = vi.spyOn(typeAheadPointer.methods, 'typeAheadSelect')
|
||||||
|
|
||||||
const onKeyDown = jest.fn()
|
const onKeyDown = vi.fn()
|
||||||
const Select = mountDefault({
|
const Select = mountDefault({
|
||||||
mapKeydown: (defaults, vm) => ({ ...defaults, 32: onKeyDown }),
|
mapKeydown: (defaults, vm) => ({ ...defaults, 32: onKeyDown }),
|
||||||
selectOnKeyCodes: [9],
|
selectOnKeyCodes: [9],
|
||||||
@@ -49,7 +49,7 @@ describe('Custom Keydown Handlers', () => {
|
|||||||
|
|
||||||
describe('CompositionEvent support', () => {
|
describe('CompositionEvent support', () => {
|
||||||
it('will not select a value with enter if the user is composing', () => {
|
it('will not select a value with enter if the user is composing', () => {
|
||||||
spy = jest.spyOn(typeAheadPointer.methods, 'typeAheadSelect')
|
spy = vi.spyOn(typeAheadPointer.methods, 'typeAheadSelect')
|
||||||
|
|
||||||
const Select = mountDefault()
|
const Select = mountDefault()
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ describe('Custom Keydown Handlers', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('will not select a value with tab if the user is composing', () => {
|
it('will not select a value with tab if the user is composing', () => {
|
||||||
spy = jest.spyOn(typeAheadPointer.methods, 'typeAheadSelect')
|
spy = vi.spyOn(typeAheadPointer.methods, 'typeAheadSelect')
|
||||||
|
|
||||||
const Select = mountDefault({ selectOnTab: true })
|
const Select = mountDefault({ selectOnTab: true })
|
||||||
|
|
||||||
|
|||||||
+22
-21
@@ -1,6 +1,7 @@
|
|||||||
import VueSelect from '../../src/components/Select'
|
import { it, describe, expect, vi } from 'vitest'
|
||||||
import { shallowMount } from '@vue/test-utils'
|
import { shallowMount } from '@vue/test-utils'
|
||||||
import { selectWithProps } from '../helpers'
|
import VueSelect from '../../src/components/Select.vue'
|
||||||
|
import { selectWithProps } from '../helpers.js'
|
||||||
|
|
||||||
describe('Labels', () => {
|
describe('Labels', () => {
|
||||||
it('can generate labels using a custom label key', () => {
|
it('can generate labels using a custom label key', () => {
|
||||||
@@ -13,7 +14,7 @@ describe('Labels', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('will console.warn when options contain objects without a valid label key', async () => {
|
it('will console.warn when options contain objects without a valid label key', async () => {
|
||||||
const spy = jest.spyOn(console, 'warn').mockImplementation(() => {})
|
const spy = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
||||||
const Select = selectWithProps({
|
const Select = selectWithProps({
|
||||||
options: [{}],
|
options: [{}],
|
||||||
})
|
})
|
||||||
@@ -63,23 +64,23 @@ describe('Labels', () => {
|
|||||||
* @see https://github.com/vuejs/vue/issues/10224
|
* @see https://github.com/vuejs/vue/issues/10224
|
||||||
* @see https://github.com/vuejs/vue/pull/10229
|
* @see https://github.com/vuejs/vue/pull/10229
|
||||||
*/
|
*/
|
||||||
xit('will not call getOptionLabel if both scoped option slots are used and a filter is provided', () => {
|
// it('will not call getOptionLabel if both scoped option slots are used and a filter is provided', () => {
|
||||||
const spy = spyOn(VueSelect.props.getOptionLabel, 'default')
|
// const spy = spyOn(VueSelect.props.getOptionLabel, 'default')
|
||||||
const Select = shallowMount(VueSelect, {
|
// const Select = shallowMount(VueSelect, {
|
||||||
props: {
|
// props: {
|
||||||
options: [{ name: 'one' }],
|
// options: [{ name: 'one' }],
|
||||||
filter: () => {},
|
// filter: () => {},
|
||||||
},
|
// },
|
||||||
scopedSlots: {
|
// scopedSlots: {
|
||||||
option: '<span class="option">{{ props.name }}</span>',
|
// option: '<span class="option">{{ props.name }}</span>',
|
||||||
'selected-option': '<span class="selected">{{ props.name }}</span>',
|
// 'selected-option': '<span class="selected">{{ props.name }}</span>',
|
||||||
},
|
// },
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
Select.vm.select({ name: 'one' })
|
// Select.vm.select({ name: 'one' })
|
||||||
|
//
|
||||||
expect(spy).toHaveBeenCalledTimes(0)
|
// expect(spy).toHaveBeenCalledTimes(0)
|
||||||
expect(Select.find('.selected').exists()).toBeTruthy()
|
// expect(Select.find('.selected').exists()).toBeTruthy()
|
||||||
})
|
// })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
import { it, describe, expect } from 'vitest'
|
||||||
import { shallowMount } from '@vue/test-utils'
|
import { shallowMount } from '@vue/test-utils'
|
||||||
import VueSelect from '../../src/components/Select'
|
import VueSelect from '../../src/components/Select.vue'
|
||||||
|
|
||||||
describe('Single value options', () => {
|
describe('Single value options', () => {
|
||||||
it('should reset the search input on focus lost', () => {
|
it('should reset the search input on focus lost', () => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import Select from '../../src/components/Select'
|
import { it, describe, expect } from 'vitest'
|
||||||
|
import Select from '../../src/components/Select.vue'
|
||||||
|
|
||||||
describe('Comparing Options', () => {
|
describe('Comparing Options', () => {
|
||||||
const comparator = Select.methods.optionComparator.bind({
|
const comparator = Select.methods.optionComparator.bind({
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { it, describe, expect } from 'vitest'
|
||||||
import Select from '../../src/components/Select.vue'
|
import Select from '../../src/components/Select.vue'
|
||||||
|
|
||||||
describe('Serializing Option Keys', () => {
|
describe('Serializing Option Keys', () => {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { mount, shallowMount } from '@vue/test-utils'
|
import { it, describe, expect, vi, afterEach } from 'vitest'
|
||||||
import VueSelect from '../../src/components/Select'
|
import { shallowMount } from '@vue/test-utils'
|
||||||
import { mountDefault } from '../helpers'
|
import VueSelect from '../../src/components/Select.vue'
|
||||||
|
import { mountDefault } from '../helpers.js'
|
||||||
|
|
||||||
describe('Reset on options change', () => {
|
describe('Reset on options change', () => {
|
||||||
it('should not reset the selected value by default when the options property changes', async () => {
|
it('should not reset the selected value by default when the options property changes', async () => {
|
||||||
@@ -21,7 +22,7 @@ describe('Reset on options change', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('will yell at you if resetOnOptionsChange is not a function or boolean', () => {
|
it('will yell at you if resetOnOptionsChange is not a function or boolean', () => {
|
||||||
spy = jest.spyOn(console, 'warn').mockImplementation(() => {})
|
spy = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
||||||
|
|
||||||
mountDefault({ resetOnOptionsChange: 1 })
|
mountDefault({ resetOnOptionsChange: 1 })
|
||||||
expect(spy.mock.calls[0][0]).toContain(
|
expect(spy.mock.calls[0][0]).toContain(
|
||||||
@@ -45,7 +46,7 @@ describe('Reset on options change', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should receive the new options, old options, and current value', async () => {
|
it('should receive the new options, old options, and current value', async () => {
|
||||||
let resetOnOptionsChange = jest.fn((option) => option)
|
let resetOnOptionsChange = vi.fn((option) => option)
|
||||||
const Select = mountDefault({
|
const Select = mountDefault({
|
||||||
resetOnOptionsChange,
|
resetOnOptionsChange,
|
||||||
options: ['bear'],
|
options: ['bear'],
|
||||||
@@ -64,7 +65,7 @@ describe('Reset on options change', () => {
|
|||||||
|
|
||||||
it('should allow resetOnOptionsChange to be a function that returns true', async () => {
|
it('should allow resetOnOptionsChange to be a function that returns true', async () => {
|
||||||
let resetOnOptionsChange = () => true
|
let resetOnOptionsChange = () => true
|
||||||
spy = jest.spyOn(VueSelect.methods, 'clearSelection')
|
spy = vi.spyOn(VueSelect.methods, 'clearSelection')
|
||||||
const Select = shallowMount(VueSelect, {
|
const Select = shallowMount(VueSelect, {
|
||||||
props: { resetOnOptionsChange, options: ['one'], modelValue: 'one' },
|
props: { resetOnOptionsChange, options: ['one'], modelValue: 'one' },
|
||||||
})
|
})
|
||||||
@@ -76,7 +77,7 @@ describe('Reset on options change', () => {
|
|||||||
|
|
||||||
it('should allow resetOnOptionsChange to be a function that returns false', () => {
|
it('should allow resetOnOptionsChange to be a function that returns false', () => {
|
||||||
let resetOnOptionsChange = () => false
|
let resetOnOptionsChange = () => false
|
||||||
spy = jest.spyOn(VueSelect.methods, 'clearSelection')
|
spy = vi.spyOn(VueSelect.methods, 'clearSelection')
|
||||||
const Select = shallowMount(VueSelect, {
|
const Select = shallowMount(VueSelect, {
|
||||||
props: { resetOnOptionsChange, options: ['one'], modelValue: 'one' },
|
props: { resetOnOptionsChange, options: ['one'], modelValue: 'one' },
|
||||||
})
|
})
|
||||||
@@ -88,7 +89,7 @@ describe('Reset on options change', () => {
|
|||||||
it('should reset the options if the selectedValue does not exist in the new options', async () => {
|
it('should reset the options if the selectedValue does not exist in the new options', async () => {
|
||||||
let resetOnOptionsChange = (options, old, val) =>
|
let resetOnOptionsChange = (options, old, val) =>
|
||||||
val.some((val) => options.includes(val))
|
val.some((val) => options.includes(val))
|
||||||
spy = jest.spyOn(VueSelect.methods, 'clearSelection')
|
spy = vi.spyOn(VueSelect.methods, 'clearSelection')
|
||||||
const Select = shallowMount(VueSelect, {
|
const Select = shallowMount(VueSelect, {
|
||||||
props: { resetOnOptionsChange, options: ['one'], modelValue: 'one' },
|
props: { resetOnOptionsChange, options: ['one'], modelValue: 'one' },
|
||||||
})
|
})
|
||||||
@@ -135,7 +136,7 @@ describe('Reset on options change', () => {
|
|||||||
|
|
||||||
it('clearSearchOnBlur returns false when multiple is true', async () => {
|
it('clearSearchOnBlur returns false when multiple is true', async () => {
|
||||||
const Select = mountDefault({})
|
const Select = mountDefault({})
|
||||||
let clearSearchOnBlur = jest.spyOn(Select.vm.$.props, 'clearSearchOnBlur')
|
let clearSearchOnBlur = vi.spyOn(Select.vm.$.props, 'clearSearchOnBlur')
|
||||||
await Select.get('input').trigger('click')
|
await Select.get('input').trigger('click')
|
||||||
Select.vm.search = 'one'
|
Select.vm.search = 'one'
|
||||||
await Select.get('input').trigger('blur')
|
await Select.get('input').trigger('blur')
|
||||||
@@ -149,7 +150,7 @@ describe('Reset on options change', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('clearSearchOnBlur accepts a function', async () => {
|
it('clearSearchOnBlur accepts a function', async () => {
|
||||||
let clearSearchOnBlur = jest.fn(() => false)
|
let clearSearchOnBlur = vi.fn(() => false)
|
||||||
const Select = mountDefault({ clearSearchOnBlur })
|
const Select = mountDefault({ clearSearchOnBlur })
|
||||||
|
|
||||||
await Select.get('input').trigger('click')
|
await Select.get('input').trigger('click')
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
import { it, describe, expect } from 'vitest'
|
||||||
import { mount, shallowMount } from '@vue/test-utils'
|
import { mount, shallowMount } from '@vue/test-utils'
|
||||||
import VueSelect from '../../src/components/Select'
|
import VueSelect from '../../src/components/Select.vue'
|
||||||
import { mountDefault } from '../helpers.js'
|
import { mountDefault } from '../helpers.js'
|
||||||
|
|
||||||
describe('When reduce prop is defined', () => {
|
describe('When reduce prop is defined', () => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { searchSubmit, selectWithProps } from '../helpers'
|
import { it, describe, expect } from 'vitest'
|
||||||
|
import { searchSubmit, selectWithProps } from '../helpers.js'
|
||||||
|
|
||||||
describe('Selectable prop', () => {
|
describe('Selectable prop', () => {
|
||||||
it('should select selectable option if clicked', async () => {
|
it('should select selectable option if clicked', async () => {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
import { it, describe, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||||
import { mount, shallowMount } from '@vue/test-utils'
|
import { mount, shallowMount } from '@vue/test-utils'
|
||||||
import VueSelect from '../../src/components/Select.vue'
|
import VueSelect from '../../src/components/Select.vue'
|
||||||
import typeAheadPointer from '../../src/mixins/typeAheadPointer'
|
import typeAheadPointer from '../../src/mixins/typeAheadPointer.js'
|
||||||
import { mountDefault } from '../helpers'
|
import { mountDefault } from '../helpers.js'
|
||||||
|
|
||||||
describe('VS - Selecting Values', () => {
|
describe('VS - Selecting Values', () => {
|
||||||
let defaultProps
|
let defaultProps
|
||||||
@@ -57,7 +58,7 @@ describe('VS - Selecting Values', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('can select an option on tab', () => {
|
it('can select an option on tab', () => {
|
||||||
spy = jest.spyOn(typeAheadPointer.methods, 'typeAheadSelect')
|
spy = vi.spyOn(typeAheadPointer.methods, 'typeAheadSelect')
|
||||||
const Select = shallowMount(VueSelect, {
|
const Select = shallowMount(VueSelect, {
|
||||||
props: {
|
props: {
|
||||||
selectOnTab: true,
|
selectOnTab: true,
|
||||||
@@ -218,7 +219,7 @@ describe('VS - Selecting Values', () => {
|
|||||||
expect(Select.vm.selectedValue).toEqual(options)
|
expect(Select.vm.selectedValue).toEqual(options)
|
||||||
})
|
})
|
||||||
|
|
||||||
fit('can select a false boolean option', async () => {
|
it('can select a false boolean option', async () => {
|
||||||
const Select = mountDefault({
|
const Select = mountDefault({
|
||||||
options: [false],
|
options: [false],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
import { it, test, describe, expect, vi } from 'vitest'
|
||||||
import { h } from 'vue'
|
import { h } from 'vue'
|
||||||
import { mountDefault } from '../helpers'
|
import { mountDefault } from '../helpers.js'
|
||||||
|
|
||||||
describe('Scoped Slots', () => {
|
describe('Scoped Slots', () => {
|
||||||
it('receives an option object to the selected-option-container slot', () => {
|
it('receives an option object to the selected-option-container slot', () => {
|
||||||
@@ -68,7 +69,7 @@ describe('Scoped Slots', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('noOptions slot receives the current search text', async () => {
|
it('noOptions slot receives the current search text', async () => {
|
||||||
const noOptions = jest.fn()
|
const noOptions = vi.fn()
|
||||||
const Select = mountDefault(
|
const Select = mountDefault(
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
@@ -88,7 +89,7 @@ describe('Scoped Slots', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('header slot props', async () => {
|
test('header slot props', async () => {
|
||||||
const header = jest.fn()
|
const header = vi.fn()
|
||||||
const Select = mountDefault(
|
const Select = mountDefault(
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
@@ -106,7 +107,7 @@ describe('Scoped Slots', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('footer slot props', async () => {
|
test('footer slot props', async () => {
|
||||||
const footer = jest.fn()
|
const footer = vi.fn()
|
||||||
const Select = mountDefault(
|
const Select = mountDefault(
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
@@ -124,7 +125,7 @@ describe('Scoped Slots', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('list-header slot props', async () => {
|
test('list-header slot props', async () => {
|
||||||
const header = jest.fn()
|
const header = vi.fn()
|
||||||
const Select = mountDefault(
|
const Select = mountDefault(
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
@@ -142,7 +143,7 @@ describe('Scoped Slots', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('list-footer slot props', async () => {
|
test('list-footer slot props', async () => {
|
||||||
const footer = jest.fn()
|
const footer = vi.fn()
|
||||||
const Select = mountDefault(
|
const Select = mountDefault(
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
import { it, describe, expect, vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
mountDefault,
|
mountDefault,
|
||||||
searchSubmit,
|
searchSubmit,
|
||||||
selectTag,
|
selectTag,
|
||||||
selectWithProps,
|
selectWithProps,
|
||||||
} from '../helpers'
|
} from '../helpers.js'
|
||||||
import VueSelect from '../../src/components/Select'
|
import VueSelect from '../../src/components/Select.vue'
|
||||||
|
|
||||||
describe('When Tagging Is Enabled', () => {
|
describe('When Tagging Is Enabled', () => {
|
||||||
it('can determine if a given option string already exists', () => {
|
it('can determine if a given option string already exists', () => {
|
||||||
@@ -222,7 +223,7 @@ describe('When Tagging Is Enabled', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not allow duplicate tags when using object options', async () => {
|
it('should not allow duplicate tags when using object options', async () => {
|
||||||
const spy = jest.spyOn(VueSelect.methods, 'select')
|
const spy = vi.spyOn(VueSelect.methods, 'select')
|
||||||
const Select = selectWithProps({
|
const Select = selectWithProps({
|
||||||
taggable: true,
|
taggable: true,
|
||||||
multiple: true,
|
multiple: true,
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
|
import { it, describe, expect } from 'vitest'
|
||||||
import { shallowMount } from '@vue/test-utils'
|
import { shallowMount } from '@vue/test-utils'
|
||||||
import VueSelect from '../../src/components/Select'
|
import VueSelect from '../../src/components/Select.vue'
|
||||||
import { mountDefault, mountWithoutTestUtils } from '../helpers'
|
import { mountDefault } from '../helpers.js'
|
||||||
import typeAheadMixin from '../../src/mixins/typeAheadPointer'
|
|
||||||
import Vue from 'vue'
|
|
||||||
|
|
||||||
describe('Moving the Typeahead Pointer', () => {
|
describe('Moving the Typeahead Pointer', () => {
|
||||||
it('should set the pointer to zero when the filteredOptions watcher is called', async () => {
|
it('should set the pointer to zero when the filteredOptions watcher is called', async () => {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { test, expect } from 'vitest'
|
||||||
import sortAndStringify from '../../../src/utility/sortAndStringify'
|
import sortAndStringify from '../../../src/utility/sortAndStringify'
|
||||||
|
|
||||||
test('it will stringify an object', () => {
|
test('it will stringify an object', () => {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { test, expect } from 'vitest'
|
||||||
import uniqueId from '../../../src/utility/uniqueId'
|
import uniqueId from '../../../src/utility/uniqueId'
|
||||||
|
|
||||||
test('it generates a unique number', () => {
|
test('it generates a unique number', () => {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export default defineConfig({
|
|||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||||
|
'~tests': fileURLToPath(new URL('./tests', import.meta.url)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
|
|||||||
Reference in New Issue
Block a user