mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-13 08:32:26 +03:00
Merge branch 'master' of https://github.com/yamsellem/vue-select into yamsellem-master
# Conflicts: # .gitignore
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
// Polyfill fn.bind() for PhantomJS
|
||||
/* eslint-disable no-extend-native */
|
||||
Function.prototype.bind = require('function-bind')
|
||||
|
||||
// require all test files (files that ends with .spec.js)
|
||||
var testsContext = require.context('./specs', true, /\.spec$/)
|
||||
testsContext.keys().forEach(testsContext)
|
||||
|
||||
// require all src files except main.js for coverage.
|
||||
// you can also change this to match only the subset of files that
|
||||
// you want coverage for.
|
||||
var srcContext = require('../../src/components/Select.vue')
|
||||
+24
-60
@@ -1,78 +1,42 @@
|
||||
// This is a karma config file. For more details see
|
||||
// http://karma-runner.github.io/0.13/config/configuration-file.html
|
||||
// we are also using it with karma-webpack
|
||||
// https://github.com/webpack/karma-webpack
|
||||
|
||||
var path = require('path')
|
||||
var merge = require('webpack-merge')
|
||||
var baseConfig = require('../../build/webpack.base.conf')
|
||||
var utils = require('../../build/utils')
|
||||
var webpack = require('webpack')
|
||||
var projectRoot = path.resolve(__dirname, '../../')
|
||||
|
||||
var webpackConfig = merge(baseConfig, {
|
||||
// use inline sourcemap for karma-sourcemap-loader
|
||||
module: {
|
||||
loaders: utils.styleLoaders()
|
||||
},
|
||||
devtool: '#inline-source-map',
|
||||
vue: {
|
||||
loaders: {
|
||||
js: 'isparta'
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': require('../../config/test.env')
|
||||
})
|
||||
]
|
||||
})
|
||||
var baseWebpackConfig = require('../../build/webpack.base.conf')
|
||||
|
||||
// no need for app entry during tests
|
||||
delete webpackConfig.entry
|
||||
|
||||
// make sure isparta loader is applied before eslint
|
||||
webpackConfig.module.preLoaders = webpackConfig.module.preLoaders || []
|
||||
webpackConfig.module.preLoaders.unshift({
|
||||
test: /\.js$/,
|
||||
loader: 'isparta',
|
||||
include: path.resolve(projectRoot, 'src')
|
||||
})
|
||||
|
||||
// only apply babel for test files when using isparta
|
||||
webpackConfig.module.loaders.some(function (loader, i) {
|
||||
if (loader.loader === 'babel') {
|
||||
loader.include = path.resolve(projectRoot, 'test/unit')
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = function (config) {
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
// to run in additional browsers:
|
||||
// 1. install corresponding karma launcher
|
||||
// http://karma-runner.github.io/0.13/config/browsers.html
|
||||
// 2. add it to the `browsers` array below.
|
||||
browsers: ['PhantomJS'],
|
||||
frameworks: ['jasmine'],
|
||||
files: [
|
||||
'../../node_modules/phantomjs-polyfill-object-assign/object-assign-polyfill.js',
|
||||
'**/*.js'
|
||||
],
|
||||
reporters: ['spec', 'coverage'],
|
||||
files: ['./index.js'],
|
||||
preprocessors: {
|
||||
'./index.js': ['webpack', 'sourcemap']
|
||||
'**/*.js': ['webpack', 'sourcemap']
|
||||
},
|
||||
webpack: webpackConfig,
|
||||
captureConsole: true,
|
||||
browserConsoleLogOptions: {
|
||||
terminal: true,
|
||||
level: ""
|
||||
},
|
||||
|
||||
webpack: merge(baseWebpackConfig, {
|
||||
entry: './dev/dev.js'
|
||||
}),
|
||||
|
||||
webpackMiddleware: {
|
||||
noInfo: true
|
||||
},
|
||||
|
||||
specReporter: {
|
||||
suppressSkipped: true
|
||||
},
|
||||
|
||||
coverageReporter: {
|
||||
dir: './coverage',
|
||||
reporters: [
|
||||
{ type: 'lcov', subdir: '.' },
|
||||
{ type: 'text-summary' }
|
||||
]
|
||||
instrumenters: { isparta: require('isparta') },
|
||||
instrumenter: {
|
||||
'**/*.js': 'isparta'
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ import Vue from 'vue'
|
||||
import vSelect from 'src/components/Select.vue'
|
||||
import pointerScroll from 'src/mixins/pointerScroll.js'
|
||||
Vue.config.productionTip = false
|
||||
// http://vue-loader.vuejs.org/en/workflow/testing-with-mocks.html
|
||||
const Mock = require('!!vue?inject!src/components/Select.vue')
|
||||
|
||||
Vue.component('v-select', vSelect)
|
||||
|
||||
@@ -70,6 +68,18 @@ function searchSubmit(vm, search = false) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace component mixins (a simple approach to mocking)
|
||||
* @param mixins
|
||||
*/
|
||||
function OverrideMixin(mixins) {
|
||||
return {
|
||||
extends: Object.assign({}, vSelect, {
|
||||
mixins: [].concat(mixins)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
describe('Select.vue', () => {
|
||||
|
||||
describe('Selecting values', () => {
|
||||
@@ -687,20 +697,18 @@ describe('Select.vue', () => {
|
||||
})
|
||||
|
||||
it('should scroll up if the pointer is above the current viewport bounds', () => {
|
||||
let methods = Object.assign(pointerScroll.methods, {
|
||||
const scrollMixin = Object.assign({}, pointerScroll, {methods: Object.assign({}, pointerScroll.methods, {
|
||||
pixelsToPointerTop() {
|
||||
return 1
|
||||
},
|
||||
viewport() {
|
||||
return {top: 2, bottom: 0}
|
||||
}
|
||||
})
|
||||
})})
|
||||
const vm = new Vue({
|
||||
template: '<div><v-select :options="[\'one\', \'two\', \'three\']"></v-select></div>',
|
||||
components: {
|
||||
'v-select': Mock({
|
||||
'../mixins/pointerScroll': {methods}
|
||||
})
|
||||
'v-select': OverrideMixin(scrollMixin)
|
||||
},
|
||||
}).$mount()
|
||||
|
||||
@@ -709,26 +717,19 @@ describe('Select.vue', () => {
|
||||
expect(vm.$children[0].scrollTo).toHaveBeenCalledWith(1)
|
||||
})
|
||||
|
||||
/**
|
||||
* @link https://github.com/vuejs/vue-loader/issues/434
|
||||
* @todo vue-loader/inject-loader fails when used twice in the same file,
|
||||
* so the mock here is abastracted to a separate file.
|
||||
*/
|
||||
xit('should scroll down if the pointer is below the current viewport bounds', () => {
|
||||
let methods = Object.assign(pointerScroll.methods, {
|
||||
pixelsToPointerBottom() {
|
||||
return 2
|
||||
},
|
||||
viewport() {
|
||||
return {top: 0, bottom: 1}
|
||||
}
|
||||
})
|
||||
it('should scroll down if the pointer is below the current viewport bounds', () => {
|
||||
const scrollMixin = Object.assign({}, pointerScroll, {methods: Object.assign({}, pointerScroll.methods, {
|
||||
pixelsToPointerBottom() {
|
||||
return 2
|
||||
},
|
||||
viewport() {
|
||||
return { top: 0, bottom: 1 }
|
||||
}
|
||||
})})
|
||||
const vm = new Vue({
|
||||
template: `<div><v-select :options="['one', 'two', 'three']"></v-select></div>`,
|
||||
components: {
|
||||
'v-select': Mock({
|
||||
'../mixins/pointerScroll': {methods}
|
||||
})
|
||||
'v-select': OverrideMixin(scrollMixin)
|
||||
},
|
||||
}).$mount()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user