mirror of
https://github.com/tenrok/vue-select.git
synced 2026-05-17 02:29:37 +03:00
98c278b2bb
BREAKING: mixins are no longer exported from the index (and will likely be converted to hooks)
34 lines
964 B
JavaScript
34 lines
964 B
JavaScript
import { it, describe, expect } from 'vitest'
|
|
import Select from '@/components/Select.vue'
|
|
|
|
describe('Comparing Options', () => {
|
|
const comparator = Select.methods.optionComparator.bind({
|
|
getOptionKey: Select.props.getOptionKey.default,
|
|
})
|
|
|
|
it('can compare numbers', () => {
|
|
expect(comparator(1, 2)).toBeFalsy()
|
|
expect(comparator(1, 1)).toBeTruthy()
|
|
})
|
|
|
|
it('can compare strings', () => {
|
|
expect(comparator('one', 'one')).toBeTruthy()
|
|
expect(comparator('one', 'two')).toBeFalsy()
|
|
})
|
|
|
|
it('can compare objects', () => {
|
|
// compare ID keys
|
|
expect(
|
|
comparator({ label: 'halo', id: 1 }, { label: 'halo', id: 2 })
|
|
).toBeFalsy()
|
|
// compare objects
|
|
expect(
|
|
comparator({ label: 'halo', value: 1 }, { label: 'halo', value: 1 })
|
|
).toBeTruthy()
|
|
// compare objects with different orders
|
|
expect(
|
|
comparator({ value: 1, label: 'halo' }, { label: 'halo', value: 1 })
|
|
).toBeTruthy()
|
|
})
|
|
})
|