2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-06-22 10:30:34 +03:00

use aliases in tests

This commit is contained in:
Jeff Sagal
2022-07-17 12:53:57 -07:00
parent d61224e753
commit 93b2fbc342
16 changed files with 28 additions and 28 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
import { it, describe, expect } from 'vitest' import { it, describe, expect } from 'vitest'
import { selectWithProps } from '../helpers.js' import { selectWithProps } from '../helpers.js'
import { shallowMount } from '@vue/test-utils' import { shallowMount } from '@vue/test-utils'
import vSelect from '../../src/components/Select.vue' import vSelect from '@/components/Select.vue'
describe('Asynchronous Loading', () => { describe('Asynchronous Loading', () => {
it('can toggle the loading class', () => { it('can toggle the loading class', () => {
+1 -1
View File
@@ -1,5 +1,5 @@
import { it, describe, expect, vi, afterEach } from 'vitest' 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' import { mountDefault } from '../helpers.js'
describe('Automatic Scrolling', () => { describe('Automatic Scrolling', () => {
+2 -2
View File
@@ -1,7 +1,7 @@
import { it, describe, expect, vi, afterEach } from 'vitest' import { it, describe, expect, vi, afterEach } from 'vitest'
import { selectWithProps } from '../helpers.js' import { selectWithProps } from '../helpers.js'
import OpenIndicator from '../../src/components/OpenIndicator.vue' import OpenIndicator from '@/components/OpenIndicator.vue'
import VueSelect from '../../src/components/Select.vue' import VueSelect from '@/components/Select.vue'
const preventDefault = vi.fn() const preventDefault = vi.fn()
+1 -1
View File
@@ -1,6 +1,6 @@
import { it, describe, expect } from 'vitest' import { it, describe, expect } from 'vitest'
import { shallowMount } from '@vue/test-utils' import { shallowMount } from '@vue/test-utils'
import VueSelect from '../../src/components/Select.vue' import VueSelect from '@/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 -1
View File
@@ -1,5 +1,5 @@
import { it, describe, expect, vi, afterEach } from 'vitest' 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' import { mountDefault } from '../helpers.js'
describe('Custom Keydown Handlers', () => { describe('Custom Keydown Handlers', () => {
+1 -1
View File
@@ -1,6 +1,6 @@
import { it, describe, expect, vi } from 'vitest' import { it, describe, expect, vi } from 'vitest'
import { shallowMount } from '@vue/test-utils' import { shallowMount } from '@vue/test-utils'
import VueSelect from '../../src/components/Select.vue' import VueSelect from '@/components/Select.vue'
import { selectWithProps } from '../helpers.js' import { selectWithProps } from '../helpers.js'
describe('Labels', () => { describe('Labels', () => {
+1 -1
View File
@@ -1,6 +1,6 @@
import { it, describe, expect } from 'vitest' import { it, describe, expect } from 'vitest'
import { shallowMount } from '@vue/test-utils' import { shallowMount } from '@vue/test-utils'
import VueSelect from '../../src/components/Select.vue' import VueSelect from '@/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 -1
View File
@@ -1,5 +1,5 @@
import { it, describe, expect } from 'vitest' import { it, describe, expect } from 'vitest'
import Select from '../../src/components/Select.vue' import Select from '@/components/Select.vue'
describe('Comparing Options', () => { describe('Comparing Options', () => {
const comparator = Select.methods.optionComparator.bind({ const comparator = Select.methods.optionComparator.bind({
+1 -1
View File
@@ -1,5 +1,5 @@
import { it, describe, expect } from 'vitest' import { it, describe, expect } from 'vitest'
import Select from '../../src/components/Select.vue' import Select from '@/components/Select.vue'
describe('Serializing Option Keys', () => { describe('Serializing Option Keys', () => {
const getOptionKey = Select.props.getOptionKey.default const getOptionKey = Select.props.getOptionKey.default
+7 -7
View File
@@ -1,6 +1,6 @@
import { it, describe, expect, vi, afterEach } from 'vitest' import { it, describe, expect, vi, afterEach } from 'vitest'
import { shallowMount } from '@vue/test-utils' import { shallowMount } from '@vue/test-utils'
import VueSelect from '../../src/components/Select.vue' import VueSelect from '@/components/Select.vue'
import { mountDefault } from '../helpers.js' import { mountDefault } from '../helpers.js'
describe('Reset on options change', () => { 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 () => { 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({ const Select = mountDefault({
resetOnOptionsChange, resetOnOptionsChange,
options: ['bear'], options: ['bear'],
@@ -64,7 +64,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 const resetOnOptionsChange = () => true
spy = vi.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 +76,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 const resetOnOptionsChange = () => false
spy = vi.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' },
@@ -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 () => { 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)) val.some((val) => options.includes(val))
spy = vi.spyOn(VueSelect.methods, 'clearSelection') spy = vi.spyOn(VueSelect.methods, 'clearSelection')
const Select = shallowMount(VueSelect, { const Select = shallowMount(VueSelect, {
@@ -136,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 = vi.spyOn(Select.vm.$.props, 'clearSearchOnBlur') const 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')
@@ -150,7 +150,7 @@ describe('Reset on options change', () => {
}) })
it('clearSearchOnBlur accepts a function', async () => { it('clearSearchOnBlur accepts a function', async () => {
let clearSearchOnBlur = vi.fn(() => false) const clearSearchOnBlur = vi.fn(() => false)
const Select = mountDefault({ clearSearchOnBlur }) const Select = mountDefault({ clearSearchOnBlur })
await Select.get('input').trigger('click') await Select.get('input').trigger('click')
+2 -2
View File
@@ -1,11 +1,11 @@
import { it, describe, expect } from 'vitest' 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.vue' import VueSelect from '@/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', () => {
it('determines when a reducer has been supplied', async () => { it('determines when a reducer has been supplied', async () => {
let Select = mountDefault() const Select = mountDefault()
expect(Select.vm.isReducingValues).toBeFalsy() expect(Select.vm.isReducingValues).toBeFalsy()
await Select.setProps({ reduce: () => {} }) await Select.setProps({ reduce: () => {} })
+2 -2
View File
@@ -1,7 +1,7 @@
import { it, describe, expect, vi, beforeEach, afterEach } from 'vitest' 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 '@/components/Select.vue'
import typeAheadPointer from '../../src/mixins/typeAheadPointer.js' import typeAheadPointer from '@/mixins/typeAheadPointer.js'
import { mountDefault } from '../helpers.js' import { mountDefault } from '../helpers.js'
describe('VS - Selecting Values', () => { describe('VS - Selecting Values', () => {
+4 -4
View File
@@ -5,7 +5,7 @@ import {
selectTag, selectTag,
selectWithProps, selectWithProps,
} from '../helpers.js' } from '../helpers.js'
import VueSelect from '../../src/components/Select.vue' import VueSelect from '@/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', () => {
@@ -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 () => { 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({ const Select = selectWithProps({
taggable: true, taggable: true,
multiple: 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 () => { 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({ const Select = selectWithProps({
taggable: true, taggable: true,
options: [{ label: 'one' }, two], 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 () => { 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({ const Select = selectWithProps({
taggable: true, taggable: true,
filterable: false, filterable: false,
+1 -1
View File
@@ -1,6 +1,6 @@
import { it, describe, expect } from 'vitest' import { it, describe, expect } from 'vitest'
import { shallowMount } from '@vue/test-utils' import { shallowMount } from '@vue/test-utils'
import VueSelect from '../../src/components/Select.vue' import VueSelect from '@/components/Select.vue'
import { mountDefault } from '../helpers.js' import { mountDefault } from '../helpers.js'
describe('Moving the Typeahead Pointer', () => { describe('Moving the Typeahead Pointer', () => {
+1 -1
View File
@@ -1,5 +1,5 @@
import { test, expect } from 'vitest' import { test, expect } from 'vitest'
import sortAndStringify from '../../../src/utility/sortAndStringify' import sortAndStringify from '@/utility/sortAndStringify'
test('it will stringify an object', () => { test('it will stringify an object', () => {
expect(sortAndStringify({ hello: 'world' })).toEqual('{"hello":"world"}') expect(sortAndStringify({ hello: 'world' })).toEqual('{"hello":"world"}')
+1 -1
View File
@@ -1,5 +1,5 @@
import { test, expect } from 'vitest' import { test, expect } from 'vitest'
import uniqueId from '../../../src/utility/uniqueId' import uniqueId from '@/utility/uniqueId'
test('it generates a unique number', () => { test('it generates a unique number', () => {
expect(uniqueId()).not.toEqual(uniqueId()) expect(uniqueId()).not.toEqual(uniqueId())