mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-04 06:32:23 +03:00
use aliases in tests
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { it, describe, expect } from 'vitest'
|
||||
import { selectWithProps } from '../helpers.js'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import vSelect from '../../src/components/Select.vue'
|
||||
import vSelect from '@/components/Select.vue'
|
||||
|
||||
describe('Asynchronous Loading', () => {
|
||||
it('can toggle the loading class', () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { it, describe, expect, vi, afterEach } from 'vitest'
|
||||
import pointerScroll from '../../src/mixins/pointerScroll.js'
|
||||
import pointerScroll from '@/mixins/pointerScroll.js'
|
||||
import { mountDefault } from '../helpers.js'
|
||||
|
||||
describe('Automatic Scrolling', () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { it, describe, expect, vi, afterEach } from 'vitest'
|
||||
import { selectWithProps } from '../helpers.js'
|
||||
import OpenIndicator from '../../src/components/OpenIndicator.vue'
|
||||
import VueSelect from '../../src/components/Select.vue'
|
||||
import OpenIndicator from '@/components/OpenIndicator.vue'
|
||||
import VueSelect from '@/components/Select.vue'
|
||||
|
||||
const preventDefault = vi.fn()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { it, describe, expect } from 'vitest'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import VueSelect from '../../src/components/Select.vue'
|
||||
import VueSelect from '@/components/Select.vue'
|
||||
|
||||
describe('Filtering Options', () => {
|
||||
it("should update the search value when the input element receives the 'input' event", () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { it, describe, expect, vi, afterEach } from 'vitest'
|
||||
import typeAheadPointer from '../../src/mixins/typeAheadPointer.js'
|
||||
import typeAheadPointer from '@/mixins/typeAheadPointer.js'
|
||||
import { mountDefault } from '../helpers.js'
|
||||
|
||||
describe('Custom Keydown Handlers', () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { it, describe, expect, vi } from 'vitest'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import VueSelect from '../../src/components/Select.vue'
|
||||
import VueSelect from '@/components/Select.vue'
|
||||
import { selectWithProps } from '../helpers.js'
|
||||
|
||||
describe('Labels', () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { it, describe, expect } from 'vitest'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import VueSelect from '../../src/components/Select.vue'
|
||||
import VueSelect from '@/components/Select.vue'
|
||||
|
||||
describe('Single value options', () => {
|
||||
it('should reset the search input on focus lost', () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { it, describe, expect } from 'vitest'
|
||||
import Select from '../../src/components/Select.vue'
|
||||
import Select from '@/components/Select.vue'
|
||||
|
||||
describe('Comparing Options', () => {
|
||||
const comparator = Select.methods.optionComparator.bind({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { it, describe, expect } from 'vitest'
|
||||
import Select from '../../src/components/Select.vue'
|
||||
import Select from '@/components/Select.vue'
|
||||
|
||||
describe('Serializing Option Keys', () => {
|
||||
const getOptionKey = Select.props.getOptionKey.default
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { it, describe, expect, vi, afterEach } from 'vitest'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import VueSelect from '../../src/components/Select.vue'
|
||||
import VueSelect from '@/components/Select.vue'
|
||||
import { mountDefault } from '../helpers.js'
|
||||
|
||||
describe('Reset on options change', () => {
|
||||
@@ -46,7 +46,7 @@ describe('Reset on options change', () => {
|
||||
})
|
||||
|
||||
it('should receive the new options, old options, and current value', async () => {
|
||||
let resetOnOptionsChange = vi.fn((option) => option)
|
||||
const resetOnOptionsChange = vi.fn((option) => option)
|
||||
const Select = mountDefault({
|
||||
resetOnOptionsChange,
|
||||
options: ['bear'],
|
||||
@@ -64,7 +64,7 @@ describe('Reset on options change', () => {
|
||||
})
|
||||
|
||||
it('should allow resetOnOptionsChange to be a function that returns true', async () => {
|
||||
let resetOnOptionsChange = () => true
|
||||
const resetOnOptionsChange = () => true
|
||||
spy = vi.spyOn(VueSelect.methods, 'clearSelection')
|
||||
const Select = shallowMount(VueSelect, {
|
||||
props: { resetOnOptionsChange, options: ['one'], modelValue: 'one' },
|
||||
@@ -76,7 +76,7 @@ describe('Reset on options change', () => {
|
||||
})
|
||||
|
||||
it('should allow resetOnOptionsChange to be a function that returns false', () => {
|
||||
let resetOnOptionsChange = () => false
|
||||
const resetOnOptionsChange = () => false
|
||||
spy = vi.spyOn(VueSelect.methods, 'clearSelection')
|
||||
const Select = shallowMount(VueSelect, {
|
||||
props: { resetOnOptionsChange, options: ['one'], modelValue: 'one' },
|
||||
@@ -87,7 +87,7 @@ describe('Reset on options change', () => {
|
||||
})
|
||||
|
||||
it('should reset the options if the selectedValue does not exist in the new options', async () => {
|
||||
let resetOnOptionsChange = (options, old, val) =>
|
||||
const resetOnOptionsChange = (options, old, val) =>
|
||||
val.some((val) => options.includes(val))
|
||||
spy = vi.spyOn(VueSelect.methods, 'clearSelection')
|
||||
const Select = shallowMount(VueSelect, {
|
||||
@@ -136,7 +136,7 @@ describe('Reset on options change', () => {
|
||||
|
||||
it('clearSearchOnBlur returns false when multiple is true', async () => {
|
||||
const Select = mountDefault({})
|
||||
let clearSearchOnBlur = vi.spyOn(Select.vm.$.props, 'clearSearchOnBlur')
|
||||
const clearSearchOnBlur = vi.spyOn(Select.vm.$.props, 'clearSearchOnBlur')
|
||||
await Select.get('input').trigger('click')
|
||||
Select.vm.search = 'one'
|
||||
await Select.get('input').trigger('blur')
|
||||
@@ -150,7 +150,7 @@ describe('Reset on options change', () => {
|
||||
})
|
||||
|
||||
it('clearSearchOnBlur accepts a function', async () => {
|
||||
let clearSearchOnBlur = vi.fn(() => false)
|
||||
const clearSearchOnBlur = vi.fn(() => false)
|
||||
const Select = mountDefault({ clearSearchOnBlur })
|
||||
|
||||
await Select.get('input').trigger('click')
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { it, describe, expect } from 'vitest'
|
||||
import { mount, shallowMount } from '@vue/test-utils'
|
||||
import VueSelect from '../../src/components/Select.vue'
|
||||
import VueSelect from '@/components/Select.vue'
|
||||
import { mountDefault } from '../helpers.js'
|
||||
|
||||
describe('When reduce prop is defined', () => {
|
||||
it('determines when a reducer has been supplied', async () => {
|
||||
let Select = mountDefault()
|
||||
const Select = mountDefault()
|
||||
expect(Select.vm.isReducingValues).toBeFalsy()
|
||||
|
||||
await Select.setProps({ reduce: () => {} })
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { it, describe, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||
import { mount, shallowMount } from '@vue/test-utils'
|
||||
import VueSelect from '../../src/components/Select.vue'
|
||||
import typeAheadPointer from '../../src/mixins/typeAheadPointer.js'
|
||||
import VueSelect from '@/components/Select.vue'
|
||||
import typeAheadPointer from '@/mixins/typeAheadPointer.js'
|
||||
import { mountDefault } from '../helpers.js'
|
||||
|
||||
describe('VS - Selecting Values', () => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
selectTag,
|
||||
selectWithProps,
|
||||
} from '../helpers.js'
|
||||
import VueSelect from '../../src/components/Select.vue'
|
||||
import VueSelect from '@/components/Select.vue'
|
||||
|
||||
describe('When Tagging Is Enabled', () => {
|
||||
it('can determine if a given option string already exists', () => {
|
||||
@@ -147,7 +147,7 @@ describe('When Tagging Is Enabled', () => {
|
||||
})
|
||||
|
||||
it('should select an existing option if the search string matches a string from options', async () => {
|
||||
let two = 'two'
|
||||
const two = 'two'
|
||||
const Select = selectWithProps({
|
||||
taggable: true,
|
||||
multiple: true,
|
||||
@@ -160,7 +160,7 @@ describe('When Tagging Is Enabled', () => {
|
||||
})
|
||||
|
||||
it('should select an existing option if the search string matches an objects label from options', async () => {
|
||||
let two = { label: 'two' }
|
||||
const two = { label: 'two' }
|
||||
const Select = selectWithProps({
|
||||
taggable: true,
|
||||
options: [{ label: 'one' }, two],
|
||||
@@ -171,7 +171,7 @@ describe('When Tagging Is Enabled', () => {
|
||||
})
|
||||
|
||||
it('should select an existing option if the search string matches an objects label from options when filter-options is false', async () => {
|
||||
let two = { label: 'two' }
|
||||
const two = { label: 'two' }
|
||||
const Select = selectWithProps({
|
||||
taggable: true,
|
||||
filterable: false,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { it, describe, expect } from 'vitest'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import VueSelect from '../../src/components/Select.vue'
|
||||
import VueSelect from '@/components/Select.vue'
|
||||
import { mountDefault } from '../helpers.js'
|
||||
|
||||
describe('Moving the Typeahead Pointer', () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { test, expect } from 'vitest'
|
||||
import sortAndStringify from '../../../src/utility/sortAndStringify'
|
||||
import sortAndStringify from '@/utility/sortAndStringify'
|
||||
|
||||
test('it will stringify an object', () => {
|
||||
expect(sortAndStringify({ hello: 'world' })).toEqual('{"hello":"world"}')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { test, expect } from 'vitest'
|
||||
import uniqueId from '../../../src/utility/uniqueId'
|
||||
import uniqueId from '@/utility/uniqueId'
|
||||
|
||||
test('it generates a unique number', () => {
|
||||
expect(uniqueId()).not.toEqual(uniqueId())
|
||||
|
||||
Reference in New Issue
Block a user