mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
Revert "Fix linter"
This commit is contained in:
@@ -3,17 +3,183 @@
|
|||||||
"html"
|
"html"
|
||||||
],
|
],
|
||||||
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 6,
|
|
||||||
"sourceType": "module"
|
|
||||||
},
|
|
||||||
|
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"node": true,
|
"node": true
|
||||||
"es6": true,
|
|
||||||
"jasmine": true
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"extends": "standard"
|
"ecmaFeatures": {
|
||||||
|
"arrowFunctions": true,
|
||||||
|
"destructuring": true,
|
||||||
|
"classes": true,
|
||||||
|
"defaultParams": true,
|
||||||
|
"blockBindings": true,
|
||||||
|
"modules": true,
|
||||||
|
"objectLiteralComputedProperties": true,
|
||||||
|
"objectLiteralShorthandMethods": true,
|
||||||
|
"objectLiteralShorthandProperties": true,
|
||||||
|
"restParams": true,
|
||||||
|
"spread": true,
|
||||||
|
"forOf": true,
|
||||||
|
"generators": true,
|
||||||
|
"templateStrings": true,
|
||||||
|
"superInFunctions": true,
|
||||||
|
"experimentalObjectRestSpread": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"rules": {
|
||||||
|
"accessor-pairs": 2,
|
||||||
|
"array-bracket-spacing": 0,
|
||||||
|
"block-scoped-var": 0,
|
||||||
|
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
|
||||||
|
"camelcase": 0,
|
||||||
|
"comma-dangle": [2, "never"],
|
||||||
|
"comma-spacing": [2, { "before": false, "after": true }],
|
||||||
|
"comma-style": [2, "last"],
|
||||||
|
"complexity": 0,
|
||||||
|
"computed-property-spacing": 0,
|
||||||
|
"consistent-return": 0,
|
||||||
|
"consistent-this": 0,
|
||||||
|
"constructor-super": 2,
|
||||||
|
"curly": [2, "multi-line"],
|
||||||
|
"default-case": 0,
|
||||||
|
"dot-location": [2, "property"],
|
||||||
|
"dot-notation": 0,
|
||||||
|
"eol-last": 2,
|
||||||
|
"eqeqeq": [2, "allow-null"],
|
||||||
|
"func-names": 0,
|
||||||
|
"func-style": 0,
|
||||||
|
"generator-star-spacing": [2, { "before": true, "after": true }],
|
||||||
|
"guard-for-in": 0,
|
||||||
|
"handle-callback-err": [2, "^(err|error)$" ],
|
||||||
|
"indent": [2, 2, { "SwitchCase": 1 }],
|
||||||
|
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
|
||||||
|
"linebreak-style": 0,
|
||||||
|
"lines-around-comment": 0,
|
||||||
|
"max-nested-callbacks": 0,
|
||||||
|
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
|
||||||
|
"new-parens": 2,
|
||||||
|
"newline-after-var": 0,
|
||||||
|
"no-alert": 0,
|
||||||
|
"no-array-constructor": 2,
|
||||||
|
"no-caller": 2,
|
||||||
|
"no-catch-shadow": 0,
|
||||||
|
"no-cond-assign": 2,
|
||||||
|
"no-console": 0,
|
||||||
|
"no-constant-condition": 0,
|
||||||
|
"no-continue": 0,
|
||||||
|
"no-control-regex": 2,
|
||||||
|
"no-debugger": 2,
|
||||||
|
"no-delete-var": 2,
|
||||||
|
"no-div-regex": 0,
|
||||||
|
"no-dupe-args": 2,
|
||||||
|
"no-dupe-keys": 2,
|
||||||
|
"no-duplicate-case": 2,
|
||||||
|
"no-else-return": 0,
|
||||||
|
"no-empty": 0,
|
||||||
|
"no-empty-character-class": 2,
|
||||||
|
"no-empty-label": 2,
|
||||||
|
"no-eq-null": 0,
|
||||||
|
"no-eval": 2,
|
||||||
|
"no-ex-assign": 2,
|
||||||
|
"no-extend-native": 2,
|
||||||
|
"no-extra-bind": 2,
|
||||||
|
"no-extra-boolean-cast": 2,
|
||||||
|
"no-extra-parens": 0,
|
||||||
|
"no-extra-semi": 0,
|
||||||
|
"no-fallthrough": 2,
|
||||||
|
"no-floating-decimal": 2,
|
||||||
|
"no-func-assign": 2,
|
||||||
|
"no-implied-eval": 2,
|
||||||
|
"no-inline-comments": 0,
|
||||||
|
"no-inner-declarations": [2, "functions"],
|
||||||
|
"no-invalid-regexp": 2,
|
||||||
|
"no-irregular-whitespace": 2,
|
||||||
|
"no-iterator": 2,
|
||||||
|
"no-label-var": 2,
|
||||||
|
"no-labels": 2,
|
||||||
|
"no-lone-blocks": 2,
|
||||||
|
"no-lonely-if": 0,
|
||||||
|
"no-loop-func": 0,
|
||||||
|
"no-mixed-requires": 0,
|
||||||
|
"no-mixed-spaces-and-tabs": 2,
|
||||||
|
"no-multi-spaces": 2,
|
||||||
|
"no-multi-str": 2,
|
||||||
|
"no-multiple-empty-lines": [2, { "max": 1 }],
|
||||||
|
"no-native-reassign": 2,
|
||||||
|
"no-negated-in-lhs": 2,
|
||||||
|
"no-nested-ternary": 0,
|
||||||
|
"no-new": 2,
|
||||||
|
"no-new-func": 0,
|
||||||
|
"no-new-object": 2,
|
||||||
|
"no-new-require": 2,
|
||||||
|
"no-new-wrappers": 2,
|
||||||
|
"no-obj-calls": 2,
|
||||||
|
"no-octal": 2,
|
||||||
|
"no-octal-escape": 2,
|
||||||
|
"no-param-reassign": 0,
|
||||||
|
"no-path-concat": 0,
|
||||||
|
"no-process-env": 0,
|
||||||
|
"no-process-exit": 0,
|
||||||
|
"no-proto": 0,
|
||||||
|
"no-redeclare": 2,
|
||||||
|
"no-regex-spaces": 2,
|
||||||
|
"no-restricted-modules": 0,
|
||||||
|
"no-return-assign": 2,
|
||||||
|
"no-script-url": 0,
|
||||||
|
"no-self-compare": 2,
|
||||||
|
"no-sequences": 2,
|
||||||
|
"no-shadow": 0,
|
||||||
|
"no-shadow-restricted-names": 2,
|
||||||
|
"no-spaced-func": 2,
|
||||||
|
"no-sparse-arrays": 2,
|
||||||
|
"no-sync": 0,
|
||||||
|
"no-ternary": 0,
|
||||||
|
"no-this-before-super": 2,
|
||||||
|
"no-throw-literal": 2,
|
||||||
|
"no-trailing-spaces": 2,
|
||||||
|
"no-undef": 2,
|
||||||
|
"no-undef-init": 2,
|
||||||
|
"no-undefined": 0,
|
||||||
|
"no-underscore-dangle": 0,
|
||||||
|
"no-unexpected-multiline": 2,
|
||||||
|
"no-unneeded-ternary": 2,
|
||||||
|
"no-unreachable": 2,
|
||||||
|
"no-unused-expressions": 0,
|
||||||
|
"no-unused-vars": [2, { "vars": "all", "args": "none" }],
|
||||||
|
"no-use-before-define": 0,
|
||||||
|
"no-var": 0,
|
||||||
|
"no-void": 0,
|
||||||
|
"no-warning-comments": 0,
|
||||||
|
"no-with": 2,
|
||||||
|
"object-curly-spacing": 0,
|
||||||
|
"object-shorthand": 0,
|
||||||
|
"one-var": [2, { "initialized": "never" }],
|
||||||
|
"operator-assignment": 0,
|
||||||
|
"operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }],
|
||||||
|
"padded-blocks": 0,
|
||||||
|
"prefer-const": 0,
|
||||||
|
"quote-props": 0,
|
||||||
|
"quotes": [2, "single", "avoid-escape"],
|
||||||
|
"radix": 2,
|
||||||
|
"semi": [2, "never"],
|
||||||
|
"semi-spacing": 0,
|
||||||
|
"sort-vars": 0,
|
||||||
|
"space-after-keywords": [2, "always"],
|
||||||
|
"space-before-blocks": [2, "always"],
|
||||||
|
"space-before-function-paren": [2, "always"],
|
||||||
|
"space-in-parens": [2, "never"],
|
||||||
|
"space-infix-ops": 2,
|
||||||
|
"space-return-throw-case": 2,
|
||||||
|
"space-unary-ops": [2, { "words": true, "nonwords": false }],
|
||||||
|
"spaced-comment": [2, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!"] }],
|
||||||
|
"strict": 0,
|
||||||
|
"use-isnan": 2,
|
||||||
|
"valid-jsdoc": 0,
|
||||||
|
"valid-typeof": 2,
|
||||||
|
"vars-on-top": 0,
|
||||||
|
"wrap-iife": [2, "any"],
|
||||||
|
"wrap-regex": 0,
|
||||||
|
"yoda": [2, "never"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-9
@@ -31,13 +31,6 @@
|
|||||||
"codeclimate-test-reporter": "^0.3.1",
|
"codeclimate-test-reporter": "^0.3.1",
|
||||||
"connect-history-api-fallback": "^1.1.0",
|
"connect-history-api-fallback": "^1.1.0",
|
||||||
"css-loader": "^0.23.0",
|
"css-loader": "^0.23.0",
|
||||||
"eslint": "^4.14.0",
|
|
||||||
"eslint-config-standard": "^11.0.0-beta.0",
|
|
||||||
"eslint-plugin-html": "^4.0.1",
|
|
||||||
"eslint-plugin-import": "^2.8.0",
|
|
||||||
"eslint-plugin-node": "^5.2.1",
|
|
||||||
"eslint-plugin-promise": "^3.6.0",
|
|
||||||
"eslint-plugin-standard": "^3.0.1",
|
|
||||||
"eventsource-polyfill": "^0.9.6",
|
"eventsource-polyfill": "^0.9.6",
|
||||||
"express": "^4.13.3",
|
"express": "^4.13.3",
|
||||||
"extract-text-webpack-plugin": "^1.0.1",
|
"extract-text-webpack-plugin": "^1.0.1",
|
||||||
@@ -81,6 +74,5 @@
|
|||||||
"webpack-dev-middleware": "^1.4.0",
|
"webpack-dev-middleware": "^1.4.0",
|
||||||
"webpack-hot-middleware": "^2.6.0",
|
"webpack-hot-middleware": "^2.6.0",
|
||||||
"webpack-merge": "^0.13.0"
|
"webpack-merge": "^0.13.0"
|
||||||
},
|
}
|
||||||
"dependencies": {}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-22
@@ -372,7 +372,7 @@
|
|||||||
type: Array,
|
type: Array,
|
||||||
default() {
|
default() {
|
||||||
return []
|
return []
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -475,7 +475,7 @@
|
|||||||
return option[this.label]
|
return option[this.label]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return option
|
return option;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -583,7 +583,7 @@
|
|||||||
dir: {
|
dir: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'auto'
|
default: 'auto'
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
@@ -614,9 +614,9 @@
|
|||||||
*/
|
*/
|
||||||
mutableValue(val, old) {
|
mutableValue(val, old) {
|
||||||
if (this.multiple) {
|
if (this.multiple) {
|
||||||
if (this.onChange) this.onChange(val)
|
this.onChange ? this.onChange(val) : null
|
||||||
} else {
|
} else {
|
||||||
if (this.onChange && val !== old) this.onChange(val)
|
this.onChange && val !== old ? this.onChange(val) : null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -700,11 +700,11 @@
|
|||||||
if (this.multiple) {
|
if (this.multiple) {
|
||||||
let ref = -1
|
let ref = -1
|
||||||
this.mutableValue.forEach((val) => {
|
this.mutableValue.forEach((val) => {
|
||||||
if (val === option || (typeof val === 'object' && val[this.label] === option[this.label])) {
|
if (val === option || typeof val === 'object' && val[this.label] === option[this.label]) {
|
||||||
ref = val
|
ref = val
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const index = this.mutableValue.indexOf(ref)
|
var index = this.mutableValue.indexOf(ref)
|
||||||
this.mutableValue.splice(index, 1)
|
this.mutableValue.splice(index, 1)
|
||||||
} else {
|
} else {
|
||||||
this.mutableValue = null
|
this.mutableValue = null
|
||||||
@@ -733,8 +733,7 @@
|
|||||||
* @return {void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
toggleDropdown(e) {
|
toggleDropdown(e) {
|
||||||
if (e.target === this.$refs.openIndicator || e.target === this.$refs.search ||
|
if (e.target === this.$refs.openIndicator || e.target === this.$refs.search || e.target === this.$refs.toggle || e.target === this.$el) {
|
||||||
e.target === this.$refs.toggle || e.target === this.$el) {
|
|
||||||
if (this.open) {
|
if (this.open) {
|
||||||
this.$refs.search.blur() // dropdown will close on blur
|
this.$refs.search.blur() // dropdown will close on blur
|
||||||
} else {
|
} else {
|
||||||
@@ -759,7 +758,8 @@
|
|||||||
selected = true
|
selected = true
|
||||||
} else if (typeof opt === 'object' && opt[this.label] === option) {
|
} else if (typeof opt === 'object' && opt[this.label] === option) {
|
||||||
selected = true
|
selected = true
|
||||||
} else if (opt === option) {
|
}
|
||||||
|
else if (opt === option) {
|
||||||
selected = true
|
selected = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -811,17 +811,9 @@
|
|||||||
* @return {this.value}
|
* @return {this.value}
|
||||||
*/
|
*/
|
||||||
maybeDeleteValue() {
|
maybeDeleteValue() {
|
||||||
let value = null
|
|
||||||
|
|
||||||
if (!this.$refs.search.value.length && this.mutableValue) {
|
if (!this.$refs.search.value.length && this.mutableValue) {
|
||||||
if (this.multiple) {
|
return this.multiple ? this.mutableValue.pop() : this.mutableValue = null
|
||||||
value = this.mutableValue.pop()
|
|
||||||
} else {
|
|
||||||
value = this.mutableValue = null
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return value
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -911,7 +903,7 @@
|
|||||||
*/
|
*/
|
||||||
searchPlaceholder() {
|
searchPlaceholder() {
|
||||||
if (this.isValueEmpty && this.placeholder) {
|
if (this.isValueEmpty && this.placeholder) {
|
||||||
return this.placeholder
|
return this.placeholder;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -953,7 +945,7 @@
|
|||||||
return !this.mutableValue.length
|
return !this.mutableValue.length
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -969,7 +961,7 @@
|
|||||||
|
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ Vue.config.devtools = true
|
|||||||
new Vue({
|
new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data: {
|
data: {
|
||||||
placeholder: 'placeholder',
|
placeholder: "placeholder",
|
||||||
value: null,
|
value: null,
|
||||||
options: countries,
|
options: countries,
|
||||||
ajaxRes: [],
|
ajaxRes: [],
|
||||||
|
|||||||
+2
-5
@@ -64,12 +64,9 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
toggleLoading(toggle = null) {
|
toggleLoading(toggle = null) {
|
||||||
if (toggle == null) {
|
if (toggle == null) {
|
||||||
this.mutableLoading = !this.mutableLoading
|
return this.mutableLoading = !this.mutableLoading
|
||||||
} else {
|
|
||||||
this.mutableLoading = toggle
|
|
||||||
}
|
}
|
||||||
|
return this.mutableLoading = toggle
|
||||||
return this.mutableLoading
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
pixelsToPointerTop() {
|
pixelsToPointerTop() {
|
||||||
let pixelsToPointerTop = 0
|
let pixelsToPointerTop = 0
|
||||||
|
|
||||||
if( this.$refs.dropdownMenu ) {
|
if( this.$refs.dropdownMenu ) {
|
||||||
for (let i = 0; i < this.typeAheadPointer; i++) {
|
for (let i = 0; i < this.typeAheadPointer; i++) {
|
||||||
pixelsToPointerTop += this.$refs.dropdownMenu.children[i].offsetHeight
|
pixelsToPointerTop += this.$refs.dropdownMenu.children[i].offsetHeight
|
||||||
@@ -76,13 +75,7 @@ module.exports = {
|
|||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
scrollTo(position) {
|
scrollTo(position) {
|
||||||
let result = null
|
return this.$refs.dropdownMenu ? this.$refs.dropdownMenu.scrollTop = position : null
|
||||||
|
},
|
||||||
if (this.$refs.dropdownMenu) {
|
|
||||||
result = this.$refs.dropdownMenu.scrollTop = position
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,14 +47,14 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
typeAheadSelect() {
|
typeAheadSelect() {
|
||||||
if( this.filteredOptions[ this.typeAheadPointer ] ) {
|
if( this.filteredOptions[ this.typeAheadPointer ] ) {
|
||||||
this.select(this.filteredOptions[this.typeAheadPointer])
|
this.select( this.filteredOptions[ this.typeAheadPointer ] );
|
||||||
} else if (this.taggable && this.search.length){
|
} else if (this.taggable && this.search.length){
|
||||||
this.select(this.search)
|
this.select(this.search)
|
||||||
}
|
}
|
||||||
|
|
||||||
if( this.clearSearchOnSelect ) {
|
if( this.clearSearchOnSelect ) {
|
||||||
this.search = ''
|
this.search = "";
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ Vue.component('v-select', vSelect)
|
|||||||
* @returns {Event}
|
* @returns {Event}
|
||||||
*/
|
*/
|
||||||
function trigger(target, event, process) {
|
function trigger(target, event, process) {
|
||||||
const e = document.createEvent('HTMLEvents')
|
var e = document.createEvent('HTMLEvents')
|
||||||
e.initEvent(event, true, true)
|
e.initEvent(event, true, true)
|
||||||
if (process) process(e)
|
if (process) process(e)
|
||||||
target.dispatchEvent(e)
|
target.dispatchEvent(e)
|
||||||
@@ -33,7 +33,7 @@ function trigger (target, event, process) {
|
|||||||
* @returns {Event}
|
* @returns {Event}
|
||||||
*/
|
*/
|
||||||
function triggerMouse(target, event, process) {
|
function triggerMouse(target, event, process) {
|
||||||
const e = document.createEvent('MouseEvent')
|
var e = document.createEvent('MouseEvent')
|
||||||
e.initEvent('event', true, true)
|
e.initEvent('event', true, true)
|
||||||
if (process) process(e)
|
if (process) process(e)
|
||||||
target.dispatchEvent(e)
|
target.dispatchEvent(e)
|
||||||
@@ -48,7 +48,7 @@ function triggerMouse (target, event, process) {
|
|||||||
* @returns {Event}
|
* @returns {Event}
|
||||||
*/
|
*/
|
||||||
function triggerFocusEvent(target, event, process) {
|
function triggerFocusEvent(target, event, process) {
|
||||||
const e = document.createEvent('FocusEvent')
|
var e = document.createEvent('FocusEvent')
|
||||||
e.initEvent('event', true, true)
|
e.initEvent('event', true, true)
|
||||||
if (process) process(e)
|
if (process) process(e)
|
||||||
target.dispatchEvent(e)
|
target.dispatchEvent(e)
|
||||||
@@ -71,6 +71,7 @@ function searchSubmit (vm, search = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('Select.vue', () => {
|
describe('Select.vue', () => {
|
||||||
|
|
||||||
describe('Selecting values', () => {
|
describe('Selecting values', () => {
|
||||||
it('can accept an array with pre-selected values', () => {
|
it('can accept an array with pre-selected values', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
@@ -130,11 +131,11 @@ describe('Select.vue', () => {
|
|||||||
}).$mount()
|
}).$mount()
|
||||||
vm.$children[0].select('foo')
|
vm.$children[0].select('foo')
|
||||||
expect(vm.$children[0].mutableValue.length).toEqual(1)
|
expect(vm.$children[0].mutableValue.length).toEqual(1)
|
||||||
})
|
}),
|
||||||
|
|
||||||
it('can deselect an option when multiple is false', () => {
|
it('can deselect an option when multiple is false', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: `<div><v-select :value="'foo'"></v-select></div>`
|
template: `<div><v-select :value="'foo'"></v-select></div>`,
|
||||||
}).$mount()
|
}).$mount()
|
||||||
vm.$children[0].deselect('foo')
|
vm.$children[0].deselect('foo')
|
||||||
expect(vm.$children[0].mutableValue).toEqual(null)
|
expect(vm.$children[0].mutableValue).toEqual(null)
|
||||||
@@ -239,14 +240,14 @@ describe('Select.vue', () => {
|
|||||||
expect(vm.value).toEqual('bar')
|
expect(vm.value).toEqual('bar')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
}),
|
||||||
|
|
||||||
it('can check if a string value is selected when the value is an object and multiple is true', () => {
|
it('can check if a string value is selected when the value is an object and multiple is true', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: `<div><v-select multiple :value="[{label: 'foo', value: 'bar'}]"></v-select></div>`
|
template: `<div><v-select multiple :value="[{label: 'foo', value: 'bar'}]"></v-select></div>`,
|
||||||
}).$mount()
|
}).$mount()
|
||||||
expect(vm.$children[0].isOptionSelected('foo')).toEqual(true)
|
expect(vm.$children[0].isOptionSelected('foo')).toEqual(true)
|
||||||
})
|
}),
|
||||||
|
|
||||||
describe('change Event', () => {
|
describe('change Event', () => {
|
||||||
it('will trigger the input event when the selection changes', (done) => {
|
it('will trigger the input event when the selection changes', (done) => {
|
||||||
@@ -279,6 +280,7 @@ describe('Select.vue', () => {
|
|||||||
expect(vm.foo).toEqual(['foo','bar'])
|
expect(vm.foo).toEqual(['foo','bar'])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -363,7 +365,7 @@ describe('Select.vue', () => {
|
|||||||
it('can close the dropdown when the el is clicked', (done) => {
|
it('can close the dropdown when the el is clicked', (done) => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select></v-select></div>',
|
template: '<div><v-select></v-select></div>',
|
||||||
components: {vSelect}
|
components: {vSelect},
|
||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
spyOn(vm.$children[0].$refs.search, 'blur')
|
spyOn(vm.$children[0].$refs.search, 'blur')
|
||||||
@@ -377,6 +379,7 @@ describe('Select.vue', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
it('closes the dropdown when an option is selected, multiple is true, and closeOnSelect option is true', (done) => {
|
it('closes the dropdown when an option is selected, multiple is true, and closeOnSelect option is true', (done) => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select ref="select" :options="options" multiple :value="value"></v-select></div>',
|
template: '<div><v-select ref="select" :options="options" multiple :value="value"></v-select></div>',
|
||||||
@@ -415,6 +418,7 @@ describe('Select.vue', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
it('should close the dropdown on search blur', () => {
|
it('should close the dropdown on search blur', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select :options="options" multiple :value="value"></v-select></div>',
|
template: '<div><v-select :options="options" multiple :value="value"></v-select></div>',
|
||||||
@@ -432,7 +436,7 @@ describe('Select.vue', () => {
|
|||||||
|
|
||||||
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', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select></v-select></div>'
|
template: '<div><v-select></v-select></div>',
|
||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
spyOn(vm.$children[0], '$emit')
|
spyOn(vm.$children[0], '$emit')
|
||||||
@@ -445,7 +449,7 @@ describe('Select.vue', () => {
|
|||||||
|
|
||||||
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', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select></v-select></div>'
|
template: '<div><v-select></v-select></div>',
|
||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
spyOn(vm.$children[0], '$emit')
|
spyOn(vm.$children[0], '$emit')
|
||||||
@@ -458,7 +462,7 @@ describe('Select.vue', () => {
|
|||||||
it('will close the dropdown on escape, if search is empty', (done) => {
|
it('will close the dropdown on escape, if search is empty', (done) => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select></v-select></div>',
|
template: '<div><v-select></v-select></div>',
|
||||||
components: {vSelect}
|
components: {vSelect},
|
||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
spyOn(vm.$children[0].$refs.search, 'blur')
|
spyOn(vm.$children[0].$refs.search, 'blur')
|
||||||
@@ -525,7 +529,7 @@ describe('Select.vue', () => {
|
|||||||
|
|
||||||
vm.$children[0].typeAheadPointer = 1
|
vm.$children[0].typeAheadPointer = 1
|
||||||
|
|
||||||
trigger(vm.$children[0].$refs.search, 'keydown', (e) => { e.keyCode = 38 })
|
trigger(vm.$children[0].$refs.search, 'keydown', (e) => e.keyCode = 38)
|
||||||
expect(vm.$children[0].typeAheadPointer).toEqual(0)
|
expect(vm.$children[0].typeAheadPointer).toEqual(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -539,7 +543,7 @@ describe('Select.vue', () => {
|
|||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
vm.$children[0].typeAheadPointer = 1
|
vm.$children[0].typeAheadPointer = 1
|
||||||
trigger(vm.$children[0].$refs.search, 'keydown', (e) => { e.keyCode = 40 })
|
trigger(vm.$children[0].$refs.search, 'keydown', (e) => e.keyCode = 40)
|
||||||
expect(vm.$children[0].typeAheadPointer).toEqual(2)
|
expect(vm.$children[0].typeAheadPointer).toEqual(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -569,7 +573,7 @@ describe('Select.vue', () => {
|
|||||||
|
|
||||||
vm.$children[0].typeAheadPointer = 1
|
vm.$children[0].typeAheadPointer = 1
|
||||||
spyOn(vm.$children[0], 'maybeAdjustScroll')
|
spyOn(vm.$children[0], 'maybeAdjustScroll')
|
||||||
trigger(vm.$children[0].$refs.search, 'keydown', (e) => { e.keyCode = 38 })
|
trigger(vm.$children[0].$refs.search, 'keydown', (e) => e.keyCode = 38)
|
||||||
expect(vm.$children[0].maybeAdjustScroll).toHaveBeenCalled()
|
expect(vm.$children[0].maybeAdjustScroll).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -583,7 +587,7 @@ describe('Select.vue', () => {
|
|||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
spyOn(vm.$children[0], 'maybeAdjustScroll')
|
spyOn(vm.$children[0], 'maybeAdjustScroll')
|
||||||
trigger(vm.$children[0].$refs.search, 'keydown', (e) => { e.keyCode = 40 })
|
trigger(vm.$children[0].$refs.search, 'keydown', (e) => e.keyCode = 40)
|
||||||
expect(vm.$children[0].maybeAdjustScroll).toHaveBeenCalled()
|
expect(vm.$children[0].maybeAdjustScroll).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -620,7 +624,7 @@ describe('Select.vue', () => {
|
|||||||
'v-select': Mock({
|
'v-select': Mock({
|
||||||
'../mixins/pointerScroll': {methods}
|
'../mixins/pointerScroll': {methods}
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
spyOn(vm.$children[0], 'scrollTo')
|
spyOn(vm.$children[0], 'scrollTo')
|
||||||
@@ -648,7 +652,7 @@ describe('Select.vue', () => {
|
|||||||
'v-select': Mock({
|
'v-select': Mock({
|
||||||
'../mixins/pointerScroll': {methods}
|
'../mixins/pointerScroll': {methods}
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
spyOn(vm.$children[0], 'scrollTo')
|
spyOn(vm.$children[0], 'scrollTo')
|
||||||
@@ -660,7 +664,7 @@ describe('Select.vue', () => {
|
|||||||
describe('Measuring pixel distances', () => {
|
describe('Measuring pixel distances', () => {
|
||||||
it('should calculate pointerHeight as the offsetHeight of the pointer element if it exists', () => {
|
it('should calculate pointerHeight as the offsetHeight of the pointer element if it exists', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: `<div><v-select :options="['one', 'two', 'three']"></v-select></div>`
|
template: `<div><v-select :options="['one', 'two', 'three']"></v-select></div>`,
|
||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
// dropdown must be open for $refs to exist
|
// dropdown must be open for $refs to exist
|
||||||
@@ -715,6 +719,7 @@ describe('Select.vue', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should remove the last item in the value array on delete keypress when multiple is true', () => {
|
it('should remove the last item in the value array on delete keypress when multiple is true', () => {
|
||||||
|
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select :options="options" v-model="value" :multiple="true"></v-select></div>',
|
template: '<div><v-select :options="options" v-model="value" :multiple="true"></v-select></div>',
|
||||||
components: {vSelect},
|
components: {vSelect},
|
||||||
@@ -761,7 +766,7 @@ describe('Select.vue', () => {
|
|||||||
it('will console.warn when options contain objects without a valid label key', (done) => {
|
it('will console.warn when options contain objects without a valid label key', (done) => {
|
||||||
spyOn(console, 'warn')
|
spyOn(console, 'warn')
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select :options="[{}]"></v-select></div>'
|
template: '<div><v-select :options="[{}]"></v-select></div>',
|
||||||
}).$mount()
|
}).$mount()
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
expect(console.warn).toHaveBeenCalledWith(
|
expect(console.warn).toHaveBeenCalledWith(
|
||||||
@@ -1033,7 +1038,7 @@ describe('Select.vue', () => {
|
|||||||
|
|
||||||
it('should not allow duplicate tags when using string options', (done) => {
|
it('should not allow duplicate tags when using string options', (done) => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: `<div><v-select ref="select" taggable multiple></v-select></div>`
|
template: `<div><v-select ref="select" taggable multiple></v-select></div>`,
|
||||||
}).$mount()
|
}).$mount()
|
||||||
vm.$refs.select.search = 'one'
|
vm.$refs.select.search = 'one'
|
||||||
searchSubmit(vm)
|
searchSubmit(vm)
|
||||||
@@ -1052,7 +1057,7 @@ describe('Select.vue', () => {
|
|||||||
|
|
||||||
it('should not allow duplicate tags when using object options', (done) => {
|
it('should not allow duplicate tags when using object options', (done) => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: `<div><v-select ref="select" taggable multiple></v-select></div>`
|
template: `<div><v-select ref="select" taggable multiple></v-select></div>`,
|
||||||
}).$mount()
|
}).$mount()
|
||||||
vm.$refs.select.search = 'one'
|
vm.$refs.select.search = 'one'
|
||||||
searchSubmit(vm)
|
searchSubmit(vm)
|
||||||
@@ -1067,13 +1072,14 @@ describe('Select.vue', () => {
|
|||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Asynchronous Loading', () => {
|
describe('Asynchronous Loading', () => {
|
||||||
it('can toggle the loading class', () => {
|
it('can toggle the loading class', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select ref="select"></v-select></div>'
|
template: '<div><v-select ref="select"></v-select></div>',
|
||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
vm.$refs.select.toggleLoading()
|
vm.$refs.select.toggleLoading()
|
||||||
@@ -1262,7 +1268,7 @@ describe('Select.vue', () => {
|
|||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
vm.$children[0].open = true
|
vm.$children[0].open = true
|
||||||
vm.$refs.select.search = 't'
|
vm.$refs.select.search = "t"
|
||||||
expect(vm.$refs.select.search).toEqual('t')
|
expect(vm.$refs.select.search).toEqual('t')
|
||||||
|
|
||||||
vm.$children[0].onSearchBlur()
|
vm.$children[0].onSearchBlur()
|
||||||
@@ -1283,7 +1289,7 @@ describe('Select.vue', () => {
|
|||||||
expect(vm.$refs.select.clearSearchOnSelect).toEqual(false)
|
expect(vm.$refs.select.clearSearchOnSelect).toEqual(false)
|
||||||
|
|
||||||
vm.$children[0].open = true
|
vm.$children[0].open = true
|
||||||
vm.$refs.select.search = 't'
|
vm.$refs.select.search = "t"
|
||||||
expect(vm.$refs.select.search).toEqual('t')
|
expect(vm.$refs.select.search).toEqual('t')
|
||||||
|
|
||||||
vm.$children[0].onSearchBlur()
|
vm.$children[0].onSearchBlur()
|
||||||
|
|||||||
Reference in New Issue
Block a user