├── .babelrc ├── .eslintrc.js ├── .gitignore ├── .travis.yml ├── LICENCE ├── README.md ├── _config.yml ├── build ├── webpack.base.conf.js └── webpack.min.conf.js ├── dist ├── FileUpload.vue ├── vue-simple-upload.min.js └── vue-simple-upload.min.js.map ├── package.json ├── src ├── FileUpload.vue └── index.js ├── test └── unit │ ├── .eslintrc │ ├── coverage │ ├── lcov-report │ │ ├── base.css │ │ ├── index.html │ │ ├── prettify.css │ │ ├── prettify.js │ │ ├── sort-arrow-sprite.png │ │ ├── sorter.js │ │ └── src │ │ │ ├── FileUpload.vue.html │ │ │ ├── index.html │ │ │ └── index.js.html │ └── lcov.info │ ├── index.js │ ├── karma.conf.js │ └── specs │ └── FileUpload.spec.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [] 3 | } 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style 4 | extends: 'standard', 5 | // required to lint *.vue files 6 | plugins: [ 7 | 'html' 8 | ], 9 | // add your custom rules here 10 | 'rules': { 11 | // allow paren-less arrow functions 12 | 'arrow-parens': 0, 13 | 14 | // allow debugger during development 15 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 16 | } 17 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules/ 3 | npm-debug.log 4 | yarn.lock -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | deploy: 3 | provider: npm 4 | email: saivarunk@gmail.com 5 | api_key: 6 | secure: Okoj2P6BSKXh7KE/VdOF1vt3qI0YkLXPkmGFyzdMeIrJu2mdwCn8INZ70zUN4WDcE2Bz5RSQFlsjfhEPRn8hWkzVsZFwyRS73LeqiIAKjjemGoKkdS06d7A4b/QSVl9W+WlVzDfx4lLYMQVJwsRkRP7IDi5M2FX1QpxHihwmsf1CR3+ZnoGk297lRu+9r4kNiPhAb3b9qQxB364nBGAsSd1L4Sn0zGeUyriGRi4kF2RZoF7EQhHhnjV1Xfez9Els0oTUDckGxAbxZp5ZEMA2d6xAqJKDSEmcPrsqYBRGJOuzAMIS7kBZvM2MEa2ssKBr5IBYJ7ZGAg2NgcxkssqTQrIZSqD+vp2zvX4EfrBUGF00nUhX+CZCUQ3vzGUffa0l/pZDFKZsW0+P/rWNsnv7ewI3LAnZri3qt9U29iQwkFjosE/M2A8xn2usQfFrApnisydW65ZMWvrryUQAO+Iga+aa0yWrgGoo/N/k2yn0WG+G6ZCOH5FNBrnVEacpCrDcdf+WOiGVB/onLVbR9YIFmem460iT2fE7EVIthkr8Ba4nnfNirSenCDZD19M6a8Mat48FfnRPkmlsYLj2cDCURsXwifuV+iCqjaiJ3as9ZoLUrMT3ZqPbDwAo14teVOU3UPvAH195DWv8T723o7z50neAH9hSIA59gwEHGxoOf6I= 7 | on: 8 | tags: false 9 | repo: saivarunk/vue-simple-upload 10 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | Copyright 2016 Varun Kruthiventi 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-simple-upload 2 | 3 | [![npm](https://img.shields.io/npm/v/vue-simple-upload.svg) ![npm](https://img.shields.io/npm/dm/vue-simple-upload.svg)](https://www.npmjs.com/package/vue-simple-upload) 4 | [![vue2](https://img.shields.io/badge/vue-2.x-brightgreen.svg)](https://vuejs.org/) 5 | [![Build Status](https://secure.travis-ci.org/saivarunk/vue-simple-upload.png?branch=master)](https://travis-ci.org/saivarunk/vue-simple-upload) 6 | 7 | An simple file upload component for vue.js. 8 | 9 | Checkout Demo on [JSFiddle](https://jsfiddle.net/saivarunk/o9vwjnar/) 10 | 11 | ## Installation 12 | 13 | `npm install vue-simple-upload` 14 | 15 | ## Usage 16 | vue-simple-upload is a UMD module, which can be used as a module in both CommonJS and AMD modular environments. 17 | When in non-modular environment, FileUpload will be registered as a global variable.

18 | 19 | ### ES6 20 | ```js 21 | 22 | import FileUpload from 'vue-simple-upload/dist/FileUpload' 23 | 24 | export default { 25 | ... 26 | components: { 27 | 'fileupload': FileUpload 28 | }, 29 | ... 30 | } 31 | ``` 32 | After that, you can use it in your templates: 33 | 34 | ```html 35 | 36 | ``` 37 | 38 | ### CommonJS 39 | ```js 40 | var Vue = require('vue') 41 | var FileUpload = require('vue-simple-upload') 42 | 43 | var YourComponent = Vue.extend({ 44 | ... 45 | components: { 46 | 'fileupload': FileUpload.FileUpload 47 | }, 48 | ... 49 | }) 50 | ``` 51 | 52 | ### Browser 53 | 54 | ```html 55 | 56 | 57 | 66 | ``` 67 | ## Usage 68 | 69 | ```vue 70 | 73 | 74 | 97 | ``` 98 | 99 | ## Props 100 | 101 | - target (String): 102 | Target endpoint to upload the file 103 | 104 | - action (String): 105 | Target action ( POST or PUT ) 106 | 107 | 108 | ## Events 109 | 110 | You can access the file upload events using v-on methods. 111 | 112 | - File Upload start event: 113 | You can access the start event using v-on:start="startUpload" 114 | 115 | ```js 116 | 117 | methods() { 118 | startUpload(e) { 119 | // start event 120 | } 121 | } 122 | 123 | ``` 124 | 125 | - File Upload finish event: 126 | You can access the start event using v-on:finish="finishUpload" 127 | 128 | ```js 129 | 130 | methods() { 131 | finishUpload(e) { 132 | // finish event 133 | } 134 | } 135 | 136 | ``` 137 | 138 | - File Upload progress event: 139 | You can access the file upload progress using v-on:progress="progress" 140 | 141 | ```js 142 | 143 | methods() { 144 | progress(e) { 145 | // listen to file upload progress 146 | } 147 | } 148 | 149 | ``` 150 | 151 | ## Todos 152 | 153 | - Multi File Upload 154 | 155 | ## License 156 | 157 | Released under the [MIT](LICENCE) License. 158 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-dinky -------------------------------------------------------------------------------- /build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | // var webpack = require('webpack') 3 | 4 | var projectRoot = path.resolve(__dirname, '../') 5 | 6 | module.exports = { 7 | entry: 'src', 8 | output: { 9 | path: path.resolve(__dirname, '../dist'), 10 | filename: 'vue-simple-upload.min.js', 11 | library: 'FileUpload', 12 | libraryTarget: 'umd' 13 | }, 14 | resolve: { 15 | extensions: ['', '.js', '.vue'], 16 | fallback: [path.join(__dirname, 'node_modules')], 17 | alias: { 18 | 'src': path.resolve(__dirname, '../src'), 19 | vue: 'vue/dist/vue.js' 20 | } 21 | }, 22 | resolveLoader: { 23 | root: path.join(__dirname, 'node_modules') 24 | }, 25 | module: { 26 | preLoaders: [{ 27 | test: /\.vue$/, 28 | loader: 'eslint', 29 | include: projectRoot, 30 | exclude: /node_modules/ 31 | }, { 32 | test: /\.js$/, 33 | loader: 'eslint', 34 | include: projectRoot, 35 | exclude: /node_modules/ 36 | }], 37 | loaders: [{ 38 | test: /\.vue$/, 39 | loader: 'vue' 40 | }, { 41 | test: /\.js$/, 42 | loader: 'babel-loader', 43 | exclude: /node_modules/ 44 | }, { 45 | test: /\.json$/, 46 | loader: 'json' 47 | }, { 48 | test: /\.html$/, 49 | loader: 'vue-html' 50 | }, { 51 | test: /\.(png|jpg|gif|svg)$/, 52 | loader: 'url', 53 | query: { 54 | limit: 10000, 55 | name: '[name].[ext]?[hash]' 56 | } 57 | }] 58 | }, 59 | eslint: { 60 | formatter: require('eslint-friendly-formatter') 61 | }, 62 | devServer: { 63 | historyApiFallback: true, 64 | noInfo: false 65 | }, 66 | devtool: '#eval-source-map' 67 | } 68 | -------------------------------------------------------------------------------- /build/webpack.min.conf.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack') 2 | const path = require('path') 3 | const CopyWebpackPlugin = require('copy-webpack-plugin') 4 | const base = require('./webpack.base.conf') 5 | 6 | var config = Object.assign({}, base) 7 | 8 | config.devtool = '#source-map' 9 | config.plugins = (config.plugins || []).concat([ 10 | new webpack.DefinePlugin({ 11 | 'process.env': { 12 | NODE_ENV: '"production"' 13 | } 14 | }), 15 | new webpack.optimize.UglifyJsPlugin({ 16 | compress: { 17 | warnings: false 18 | } 19 | }), 20 | new webpack.optimize.OccurenceOrderPlugin(), 21 | new CopyWebpackPlugin([{ 22 | from: path.resolve(__dirname, '../src') + './FileUpload.vue' 23 | }]) 24 | ]) 25 | 26 | module.exports = config -------------------------------------------------------------------------------- /dist/FileUpload.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | -------------------------------------------------------------------------------- /dist/vue-simple-upload.min.js: -------------------------------------------------------------------------------- 1 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FileUpload=t():e.FileUpload=t()}(this,function(){return function(e){function t(n){if(o[n])return o[n].exports;var i=o[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var i=o(3),r=n(i);e.exports={FileUpload:r.default}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"fileupload",props:{target:{type:String},action:{type:String,default:"POST"}},data:function(){return{file:null}},methods:{emitter:function(e,t){this.$emit(e,t)},uploadProgress:function(e){var t=this;if(e.lengthComputable){var o=Math.round(100*e.loaded/e.total);t.emitter("progress",o)}else t.emitter("progress",!1)},onFileChange:function(e){var t=this;if(this.target&&""!==this.target)if(this.action&&""!==this.action)if("POST"!==this.action&&"PUT"!==this.action)console.log("File upload component only allows POST and PUT Actions");else{var o=e.target.files||e.dataTransfer.files;if(!o.length)return;this.file=o[0];var n=new FormData;n.append("file",this.file);var i=new XMLHttpRequest;i.open(this.action,this.target),i.onloadstart=function(e){t.emitter("start",e)},i.onloadend=function(e){t.emitter("finish",e)},i.upload.onprogress=t.uploadProgress,i.send(n)}else console.log("Please provide file upload action ( POST / PUT )");else console.log("Please provide the target url")}}}},function(e,t){e.exports=" "},function(e,t,o){var n,i,r={};n=o(1),i=o(2),e.exports=n||{},e.exports.__esModule&&(e.exports=e.exports.default);var s="function"==typeof e.exports?e.exports.options||(e.exports.options={}):e.exports;i&&(s.template=i),s.computed||(s.computed={}),Object.keys(r).forEach(function(e){var t=r[e];s.computed[e]=function(){return t}})}])}); 2 | //# sourceMappingURL=vue-simple-upload.min.js.map -------------------------------------------------------------------------------- /dist/vue-simple-upload.min.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///vue-simple-upload.min.js","webpack:///webpack/bootstrap d7f977620c5c3c299dea","webpack:///./src/index.js","webpack:///FileUpload.vue","webpack:///./src/FileUpload.vue?9868","webpack:///./src/FileUpload.vue"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_interopRequireDefault","obj","__esModule","default","_FileUpload","_FileUpload2","FileUpload","Object","defineProperty","value","name","props","target","type","String","action","data","file","methods","emitter","event","$emit","uploadProgress","oEvent","vm","lengthComputable","percentComplete","Math","round","total","onFileChange","e","console","log","files","dataTransfer","length","formData","FormData","append","xhr","XMLHttpRequest","open","onloadstart","onloadend","upload","onprogress","send","__vue_script__","__vue_template__","__vue_styles__","__vue_options__","options","template","computed","keys","forEach","key"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,WAAAD,IAEAD,EAAA,WAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAP,WACAS,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,QAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KAqCA,OATAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,GAGAR,EAAA,KDgBM,SAASL,EAAQD,EAASM,GAE/B,YAMA,SAASS,GAAuBC,GAAO,MAAOA,IAAOA,EAAIC,WAAaD,GAAQE,QAASF,GE9DxF,GAAAG,GAAAb,EAAA,GF4DKc,EAAeL,EAAuBI,EE1D3ClB,GAAOD,SACLqB,uBFmEI,SAASpB,EAAQD,GAEtB,YAEAsB,QAAOC,eAAevB,EAAS,cAC7BwB,OAAO,IAETxB,EAAQkB,SACNO,KGvEH,aHwEGC,OACEC,QACEC,KGtEPC,QHwEKC,QACEF,KGvEPC,OHwEOX,QGrEP,SHwEGa,KAAM,WACJ,OACEC,KGtEP,OH0EGC,SACEC,QAAS,SAAiBC,EAAOJ,GAC/B3B,KAAKgC,MAAMD,EGxElBJ,IH0EKM,eAAgB,SAAwBC,GACtC,GAAIC,GGxEXnC,IHyEO,IAAIkC,EAAOE,iBGxElB,CHyES,GAAIC,GAAkBC,KAAKC,MAAsB,IAAhBL,EAAO5B,OAAe4B,EGxEhEM,MHyESL,GAAGL,QAAQ,WGxEpBO,OH0ESF,GAAGL,QAAQ,YGvEpB,IH0EKW,aAAc,SAAsBC,GAClC,GAAIP,GGtEXnC,IHwEO,IAAKA,KAAKuB,QAA0B,KAAhBvB,KAAKuB,OAElB,GAAKvB,KAAK0B,QAA0B,KAAhB1B,KAAK0B,OAEzB,GAAoB,SAAhB1B,KAAK0B,QAAqC,QAAhB1B,KAAK0B,OACxCiB,QAAQC,IGvEjB,8DACA,CHwES,GAAIC,GAAQH,EAAEnB,OAAOsB,OAASH,EAAEI,aGtEzCD,KHwES,KAAKA,EAAME,OGtEpB,MH0ES/C,MAAK4B,KAAOiB,EGpErB,EHqES,IAAIG,GAAW,GGpExBC,SHqESD,GAASE,OAAO,OAAQlD,KGnEjC4B,KHqES,IAAIuB,GAAM,GGpEnBC,eHqESD,GAAIE,KAAKrD,KAAK0B,OAAQ1B,KGnE/BuB,QHqES4B,EAAIG,YAAc,SAAUZ,GAC1BP,EAAGL,QAAQ,QGpEtBY,IHsESS,EAAII,UAAY,SAAUb,GACxBP,EAAGL,QAAQ,SGpEtBY,IHsESS,EAAIK,OAAOC,WAAatB,EGpEjCF,eHqESkB,EAAIO,KGpEbV,OH4CSL,SAAQC,IGvEjB,wDHqESD,SAAQC,IGvEjB,qCHyGM,SAAS/C,EAAQD,GIjJvBC,EAAAD,QAAA,4DJuJM,SAASC,EAAQD,EAASM,GKvJhC,GAAAyD,GAAAC,EACAC,IACAF,GAAAzD,EAAA,GACA0D,EAAA1D,EAAA,GACAL,EAAAD,QAAA+D,MACA9D,EAAAD,QAAAiB,aAAAhB,EAAAD,QAAAC,EAAAD,QAAAkB,QACA,IAAAgD,GAAA,kBAAAjE,GAAAD,QAAAC,EAAAD,QAAAmE,UAAAlE,EAAAD,QAAAmE,YAAoHlE,EAAAD,OACpHgE,KACAE,EAAAE,SAAAJ,GAEAE,EAAAG,WAAAH,EAAAG,aACA/C,OAAAgD,KAAAL,GAAAM,QAAA,SAAAC,GACA,GAAAvE,GAAAgE,EAAAO,EACAN,GAAAG,SAAAG,GAAA,WAA6C,MAAAvE","file":"vue-simple-upload.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"FileUpload\"] = factory();\n\telse\n\t\troot[\"FileUpload\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"FileUpload\"] = factory();\n\telse\n\t\troot[\"FileUpload\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar _FileUpload = __webpack_require__(3);\n\t\n\tvar _FileUpload2 = _interopRequireDefault(_FileUpload);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tmodule.exports = {\n\t FileUpload: _FileUpload2.default\n\t};\n\n/***/ },\n/* 1 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\texports.default = {\n\t name: 'fileupload',\n\t props: {\n\t target: {\n\t type: String\n\t },\n\t action: {\n\t type: String,\n\t default: 'POST'\n\t }\n\t },\n\t data: function data() {\n\t return {\n\t file: null\n\t };\n\t },\n\t\n\t methods: {\n\t emitter: function emitter(event, data) {\n\t this.$emit(event, data);\n\t },\n\t uploadProgress: function uploadProgress(oEvent) {\n\t var vm = this;\n\t if (oEvent.lengthComputable) {\n\t var percentComplete = Math.round(oEvent.loaded * 100 / oEvent.total);\n\t vm.emitter('progress', percentComplete);\n\t } else {\n\t vm.emitter('progress', false);\n\t }\n\t },\n\t onFileChange: function onFileChange(e) {\n\t var vm = this;\n\t\n\t if (!this.target || this.target === '') {\n\t console.log('Please provide the target url');\n\t } else if (!this.action || this.action === '') {\n\t console.log('Please provide file upload action ( POST / PUT )');\n\t } else if (this.action !== 'POST' && this.action !== 'PUT') {\n\t console.log('File upload component only allows POST and PUT Actions');\n\t } else {\n\t var files = e.target.files || e.dataTransfer.files;\n\t\n\t if (!files.length) {\n\t return;\n\t };\n\t\n\t this.file = files[0];\n\t var formData = new FormData();\n\t formData.append('file', this.file);\n\t\n\t var xhr = new XMLHttpRequest();\n\t xhr.open(this.action, this.target);\n\t\n\t xhr.onloadstart = function (e) {\n\t vm.emitter('start', e);\n\t };\n\t xhr.onloadend = function (e) {\n\t vm.emitter('finish', e);\n\t };\n\t xhr.upload.onprogress = vm.uploadProgress;\n\t xhr.send(formData);\n\t }\n\t }\n\t }\n\t};\n\n/***/ },\n/* 2 */\n/***/ function(module, exports) {\n\n\tmodule.exports = \" \";\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\tvar __vue_script__, __vue_template__\n\tvar __vue_styles__ = {}\n\t__vue_script__ = __webpack_require__(1)\n\t__vue_template__ = __webpack_require__(2)\n\tmodule.exports = __vue_script__ || {}\n\tif (module.exports.__esModule) module.exports = module.exports.default\n\tvar __vue_options__ = typeof module.exports === \"function\" ? (module.exports.options || (module.exports.options = {})) : module.exports\n\tif (__vue_template__) {\n\t__vue_options__.template = __vue_template__\n\t}\n\tif (!__vue_options__.computed) __vue_options__.computed = {}\n\tObject.keys(__vue_styles__).forEach(function (key) {\n\tvar module = __vue_styles__[key]\n\t__vue_options__.computed[key] = function () { return module }\n\t})\n\n\n/***/ }\n/******/ ])\n});\n;\n\n\n// WEBPACK FOOTER //\n// vue-simple-upload.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap d7f977620c5c3c299dea","import FileUpload from './FileUpload'\n\nmodule.exports = {\n FileUpload: FileUpload\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js","\n\n\n\n\n// WEBPACK FOOTER //\n// FileUpload.vue?0c0f0b66","module.exports = \" \";\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/vue-html-loader!./~/vue-loader/lib/selector.js?type=template&index=0!./src/FileUpload.vue\n// module id = 2\n// module chunks = 0","var __vue_script__, __vue_template__\nvar __vue_styles__ = {}\n__vue_script__ = require(\"!!babel-loader?presets[]=es2015&plugins[]=transform-runtime&comments=false!./../node_modules/vue-loader/lib/selector.js?type=script&index=0!./FileUpload.vue\")\n__vue_template__ = require(\"!!vue-html-loader!./../node_modules/vue-loader/lib/selector.js?type=template&index=0!./FileUpload.vue\")\nmodule.exports = __vue_script__ || {}\nif (module.exports.__esModule) module.exports = module.exports.default\nvar __vue_options__ = typeof module.exports === \"function\" ? (module.exports.options || (module.exports.options = {})) : module.exports\nif (__vue_template__) {\n__vue_options__.template = __vue_template__\n}\nif (!__vue_options__.computed) __vue_options__.computed = {}\nObject.keys(__vue_styles__).forEach(function (key) {\nvar module = __vue_styles__[key]\n__vue_options__.computed[key] = function () { return module }\n})\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/FileUpload.vue\n// module id = 3\n// module chunks = 0"],"sourceRoot":""} -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-simple-upload", 3 | "version": "0.1.6", 4 | "description": "Simple File upload component for Vue.js", 5 | "author": "saivarunk@gmail.com", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/saivarunk/vue-simple-upload" 9 | }, 10 | "keywords": [ 11 | "file-upload", 12 | "uploader", 13 | "vue" 14 | ], 15 | "scripts": { 16 | "start": "webpack-dev-server --inline --config build/webpack.base.conf.js", 17 | "build": "cross-env NODE_ENV=production webpack --config build/webpack.min.conf.js", 18 | "test": "karma start test/unit/karma.conf.js --single-run" 19 | }, 20 | "main": "dist/vue-simple-upload.min.js", 21 | "devDependencies": { 22 | "babel-core": "^6.21.0", 23 | "babel-loader": "^6.2.10", 24 | "babel-plugin-transform-runtime": "^6.0.0", 25 | "babel-preset-es2015": "^6.0.0", 26 | "babel-preset-stage-2": "^6.0.0", 27 | "babel-runtime": "^6.20.0", 28 | "chai": "^3.5.0", 29 | "copy-webpack-plugin": "^1.1.1", 30 | "cross-env": "^1.0.6", 31 | "css-loader": "^0.23.0", 32 | "eslint": "^2.0.0", 33 | "eslint-config-standard": "^5.1.0", 34 | "eslint-friendly-formatter": "^1.2.2", 35 | "eslint-loader": "^1.3.0", 36 | "eslint-plugin-html": "^1.3.0", 37 | "eslint-plugin-promise": "^1.0.8", 38 | "eslint-plugin-standard": "^1.3.2", 39 | "file-loader": "^0.8.4", 40 | "function-bind": "^1.0.2", 41 | "isparta-loader": "^2.0.0", 42 | "jasmine-core": "^2.5.2", 43 | "json-loader": "^0.5.4", 44 | "karma": "^1.4.0", 45 | "karma-coverage": "^0.5.5", 46 | "karma-jasmine": "^1.1.0", 47 | "karma-mocha": "^0.2.2", 48 | "karma-phantomjs-launcher": "^1.0.2", 49 | "karma-sinon-chai": "^1.2.0", 50 | "karma-sourcemap-loader": "^0.3.7", 51 | "karma-spec-reporter": "0.0.24", 52 | "karma-webpack": "^2.0.1", 53 | "lolex": "^1.4.0", 54 | "mocha": "^2.4.5", 55 | "ora": "^0.2.0", 56 | "phantomjs": "^2.1.7", 57 | "phantomjs-prebuilt": "^2.1.3", 58 | "sinon": "^2.1.0", 59 | "sinon-chai": "^2.8.0", 60 | "url-loader": "^0.5.7", 61 | "vue": "^2.0.0", 62 | "vue-hot-reload-api": "^1.2.0", 63 | "vue-html-loader": "^1.0.0", 64 | "vue-loader": "^8.2.1", 65 | "vue-style-loader": "^1.0.0", 66 | "webpack": "^1.14.0", 67 | "webpack-dev-server": "^1.12.0", 68 | "webpack-merge": "^0.8.3" 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/FileUpload.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 91 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import FileUpload from './FileUpload' 2 | 3 | module.exports = { 4 | FileUpload: FileUpload 5 | } 6 | -------------------------------------------------------------------------------- /test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "mocha": true 4 | }, 5 | "globals": { 6 | "expect": true, 7 | "sinon": true 8 | } 9 | } -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/base.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | margin:0; padding: 0; 3 | height: 100%; 4 | } 5 | body { 6 | font-family: Helvetica Neue, Helvetica, Arial; 7 | font-size: 14px; 8 | color:#333; 9 | } 10 | .small { font-size: 12px; } 11 | *, *:after, *:before { 12 | -webkit-box-sizing:border-box; 13 | -moz-box-sizing:border-box; 14 | box-sizing:border-box; 15 | } 16 | h1 { font-size: 20px; margin: 0;} 17 | h2 { font-size: 14px; } 18 | pre { 19 | font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; 20 | margin: 0; 21 | padding: 0; 22 | -moz-tab-size: 2; 23 | -o-tab-size: 2; 24 | tab-size: 2; 25 | } 26 | a { color:#0074D9; text-decoration:none; } 27 | a:hover { text-decoration:underline; } 28 | .strong { font-weight: bold; } 29 | .space-top1 { padding: 10px 0 0 0; } 30 | .pad2y { padding: 20px 0; } 31 | .pad1y { padding: 10px 0; } 32 | .pad2x { padding: 0 20px; } 33 | .pad2 { padding: 20px; } 34 | .pad1 { padding: 10px; } 35 | .space-left2 { padding-left:55px; } 36 | .space-right2 { padding-right:20px; } 37 | .center { text-align:center; } 38 | .clearfix { display:block; } 39 | .clearfix:after { 40 | content:''; 41 | display:block; 42 | height:0; 43 | clear:both; 44 | visibility:hidden; 45 | } 46 | .fl { float: left; } 47 | @media only screen and (max-width:640px) { 48 | .col3 { width:100%; max-width:100%; } 49 | .hide-mobile { display:none!important; } 50 | } 51 | 52 | .quiet { 53 | color: #7f7f7f; 54 | color: rgba(0,0,0,0.5); 55 | } 56 | .quiet a { opacity: 0.7; } 57 | 58 | .fraction { 59 | font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; 60 | font-size: 10px; 61 | color: #555; 62 | background: #E8E8E8; 63 | padding: 4px 5px; 64 | border-radius: 3px; 65 | vertical-align: middle; 66 | } 67 | 68 | div.path a:link, div.path a:visited { color: #333; } 69 | table.coverage { 70 | border-collapse: collapse; 71 | margin: 10px 0 0 0; 72 | padding: 0; 73 | } 74 | 75 | table.coverage td { 76 | margin: 0; 77 | padding: 0; 78 | vertical-align: top; 79 | } 80 | table.coverage td.line-count { 81 | text-align: right; 82 | padding: 0 5px 0 20px; 83 | } 84 | table.coverage td.line-coverage { 85 | text-align: right; 86 | padding-right: 10px; 87 | min-width:20px; 88 | } 89 | 90 | table.coverage td span.cline-any { 91 | display: inline-block; 92 | padding: 0 5px; 93 | width: 100%; 94 | } 95 | .missing-if-branch { 96 | display: inline-block; 97 | margin-right: 5px; 98 | border-radius: 3px; 99 | position: relative; 100 | padding: 0 4px; 101 | background: #333; 102 | color: yellow; 103 | } 104 | 105 | .skip-if-branch { 106 | display: none; 107 | margin-right: 10px; 108 | position: relative; 109 | padding: 0 4px; 110 | background: #ccc; 111 | color: white; 112 | } 113 | .missing-if-branch .typ, .skip-if-branch .typ { 114 | color: inherit !important; 115 | } 116 | .coverage-summary { 117 | border-collapse: collapse; 118 | width: 100%; 119 | } 120 | .coverage-summary tr { border-bottom: 1px solid #bbb; } 121 | .keyline-all { border: 1px solid #ddd; } 122 | .coverage-summary td, .coverage-summary th { padding: 10px; } 123 | .coverage-summary tbody { border: 1px solid #bbb; } 124 | .coverage-summary td { border-right: 1px solid #bbb; } 125 | .coverage-summary td:last-child { border-right: none; } 126 | .coverage-summary th { 127 | text-align: left; 128 | font-weight: normal; 129 | white-space: nowrap; 130 | } 131 | .coverage-summary th.file { border-right: none !important; } 132 | .coverage-summary th.pct { } 133 | .coverage-summary th.pic, 134 | .coverage-summary th.abs, 135 | .coverage-summary td.pct, 136 | .coverage-summary td.abs { text-align: right; } 137 | .coverage-summary td.file { white-space: nowrap; } 138 | .coverage-summary td.pic { min-width: 120px !important; } 139 | .coverage-summary tfoot td { } 140 | 141 | .coverage-summary .sorter { 142 | height: 10px; 143 | width: 7px; 144 | display: inline-block; 145 | margin-left: 0.5em; 146 | background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; 147 | } 148 | .coverage-summary .sorted .sorter { 149 | background-position: 0 -20px; 150 | } 151 | .coverage-summary .sorted-desc .sorter { 152 | background-position: 0 -10px; 153 | } 154 | .status-line { height: 10px; } 155 | /* dark red */ 156 | .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } 157 | .low .chart { border:1px solid #C21F39 } 158 | /* medium red */ 159 | .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } 160 | /* light red */ 161 | .low, .cline-no { background:#FCE1E5 } 162 | /* light green */ 163 | .high, .cline-yes { background:rgb(230,245,208) } 164 | /* medium green */ 165 | .cstat-yes { background:rgb(161,215,106) } 166 | /* dark green */ 167 | .status-line.high, .high .cover-fill { background:rgb(77,146,33) } 168 | .high .chart { border:1px solid rgb(77,146,33) } 169 | /* dark yellow (gold) */ 170 | .medium .chart { border:1px solid #f9cd0b; } 171 | .status-line.medium, .medium .cover-fill { background: #f9cd0b; } 172 | /* light yellow */ 173 | .medium { background: #fff4c2; } 174 | /* light gray */ 175 | span.cline-neutral { background: #eaeaea; } 176 | 177 | .cbranch-no { background: yellow !important; color: #111; } 178 | 179 | .cstat-skip { background: #ddd; color: #111; } 180 | .fstat-skip { background: #ddd; color: #111 !important; } 181 | .cbranch-skip { background: #ddd !important; color: #111; } 182 | 183 | 184 | .cover-fill, .cover-empty { 185 | display:inline-block; 186 | height: 12px; 187 | } 188 | .chart { 189 | line-height: 0; 190 | } 191 | .cover-empty { 192 | background: white; 193 | } 194 | .cover-full { 195 | border-right: none !important; 196 | } 197 | pre.prettyprint { 198 | border: none !important; 199 | padding: 0 !important; 200 | margin: 0 !important; 201 | } 202 | .com { color: #999 !important; } 203 | .ignore-none { color: #999; font-weight: normal; } 204 | 205 | .wrapper { 206 | min-height: 100%; 207 | height: auto !important; 208 | height: 100%; 209 | margin: 0 auto -48px; 210 | } 211 | .footer, .push { 212 | height: 48px; 213 | } 214 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for All files 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | / 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 5/5 26 |
27 |
28 | 100% 29 | Branches 30 | 4/4 31 |
32 |
33 | 100% 34 | Functions 35 | 1/1 36 |
37 |
38 | 100% 39 | Lines 40 | 3/3 41 |
42 |
43 | 1 branch 44 | Ignored      45 |
46 |
47 |
48 |
49 |
50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
FileStatementsBranchesFunctionsLines
src/
100%5/5100%4/4100%1/1100%3/3
80 |
81 |
82 | 86 | 87 | 88 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} 2 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/prettify.js: -------------------------------------------------------------------------------- 1 | window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); 2 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/sort-arrow-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saivarunk/vue-simple-upload/4fcb85c7e98a91a3a0ab6c4dbc01fe1da1618b81/test/unit/coverage/lcov-report/sort-arrow-sprite.png -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/sorter.js: -------------------------------------------------------------------------------- 1 | var addSorting = (function () { 2 | "use strict"; 3 | var cols, 4 | currentSort = { 5 | index: 0, 6 | desc: false 7 | }; 8 | 9 | // returns the summary table element 10 | function getTable() { return document.querySelector('.coverage-summary'); } 11 | // returns the thead element of the summary table 12 | function getTableHeader() { return getTable().querySelector('thead tr'); } 13 | // returns the tbody element of the summary table 14 | function getTableBody() { return getTable().querySelector('tbody'); } 15 | // returns the th element for nth column 16 | function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } 17 | 18 | // loads all columns 19 | function loadColumns() { 20 | var colNodes = getTableHeader().querySelectorAll('th'), 21 | colNode, 22 | cols = [], 23 | col, 24 | i; 25 | 26 | for (i = 0; i < colNodes.length; i += 1) { 27 | colNode = colNodes[i]; 28 | col = { 29 | key: colNode.getAttribute('data-col'), 30 | sortable: !colNode.getAttribute('data-nosort'), 31 | type: colNode.getAttribute('data-type') || 'string' 32 | }; 33 | cols.push(col); 34 | if (col.sortable) { 35 | col.defaultDescSort = col.type === 'number'; 36 | colNode.innerHTML = colNode.innerHTML + ''; 37 | } 38 | } 39 | return cols; 40 | } 41 | // attaches a data attribute to every tr element with an object 42 | // of data values keyed by column name 43 | function loadRowData(tableRow) { 44 | var tableCols = tableRow.querySelectorAll('td'), 45 | colNode, 46 | col, 47 | data = {}, 48 | i, 49 | val; 50 | for (i = 0; i < tableCols.length; i += 1) { 51 | colNode = tableCols[i]; 52 | col = cols[i]; 53 | val = colNode.getAttribute('data-value'); 54 | if (col.type === 'number') { 55 | val = Number(val); 56 | } 57 | data[col.key] = val; 58 | } 59 | return data; 60 | } 61 | // loads all row data 62 | function loadData() { 63 | var rows = getTableBody().querySelectorAll('tr'), 64 | i; 65 | 66 | for (i = 0; i < rows.length; i += 1) { 67 | rows[i].data = loadRowData(rows[i]); 68 | } 69 | } 70 | // sorts the table using the data for the ith column 71 | function sortByIndex(index, desc) { 72 | var key = cols[index].key, 73 | sorter = function (a, b) { 74 | a = a.data[key]; 75 | b = b.data[key]; 76 | return a < b ? -1 : a > b ? 1 : 0; 77 | }, 78 | finalSorter = sorter, 79 | tableBody = document.querySelector('.coverage-summary tbody'), 80 | rowNodes = tableBody.querySelectorAll('tr'), 81 | rows = [], 82 | i; 83 | 84 | if (desc) { 85 | finalSorter = function (a, b) { 86 | return -1 * sorter(a, b); 87 | }; 88 | } 89 | 90 | for (i = 0; i < rowNodes.length; i += 1) { 91 | rows.push(rowNodes[i]); 92 | tableBody.removeChild(rowNodes[i]); 93 | } 94 | 95 | rows.sort(finalSorter); 96 | 97 | for (i = 0; i < rows.length; i += 1) { 98 | tableBody.appendChild(rows[i]); 99 | } 100 | } 101 | // removes sort indicators for current column being sorted 102 | function removeSortIndicators() { 103 | var col = getNthColumn(currentSort.index), 104 | cls = col.className; 105 | 106 | cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); 107 | col.className = cls; 108 | } 109 | // adds sort indicators for current column being sorted 110 | function addSortIndicators() { 111 | getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; 112 | } 113 | // adds event listeners for all sorter widgets 114 | function enableUI() { 115 | var i, 116 | el, 117 | ithSorter = function ithSorter(i) { 118 | var col = cols[i]; 119 | 120 | return function () { 121 | var desc = col.defaultDescSort; 122 | 123 | if (currentSort.index === i) { 124 | desc = !currentSort.desc; 125 | } 126 | sortByIndex(i, desc); 127 | removeSortIndicators(); 128 | currentSort.index = i; 129 | currentSort.desc = desc; 130 | addSortIndicators(); 131 | }; 132 | }; 133 | for (i =0 ; i < cols.length; i += 1) { 134 | if (cols[i].sortable) { 135 | // add the click event handler on the th so users 136 | // dont have to click on those tiny arrows 137 | el = getNthColumn(i).querySelector('.sorter').parentElement; 138 | if (el.addEventListener) { 139 | el.addEventListener('click', ithSorter(i)); 140 | } else { 141 | el.attachEvent('onclick', ithSorter(i)); 142 | } 143 | } 144 | } 145 | } 146 | // adds sorting functionality to the UI 147 | return function () { 148 | if (!getTable()) { 149 | return; 150 | } 151 | cols = loadColumns(); 152 | loadData(cols); 153 | addSortIndicators(); 154 | enableUI(); 155 | }; 156 | })(); 157 | 158 | window.addEventListener('load', addSorting); 159 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/FileUpload.vue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/FileUpload.vue 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / src/ FileUpload.vue 20 |

21 |
22 |
23 | 10% 24 | Statements 25 | 3/30 26 |
27 |
28 | 0% 29 | Branches 30 | 0/18 31 |
32 |
33 | 16.67% 34 | Functions 35 | 1/6 36 |
37 |
38 | 6.9% 39 | Lines 40 | 2/29 41 |
42 |
43 |
44 |
45 |

 46 | 
272 | 
1 47 | 2 48 | 3 49 | 4 50 | 5 51 | 6 52 | 7 53 | 8 54 | 9 55 | 10 56 | 11 57 | 12 58 | 13 59 | 14 60 | 15 61 | 16 62 | 17 63 | 18 64 | 19 65 | 20 66 | 21 67 | 22 68 | 23 69 | 24 70 | 25 71 | 26 72 | 27 73 | 28 74 | 29 75 | 30 76 | 31 77 | 32 78 | 33 79 | 34 80 | 35 81 | 36 82 | 37 83 | 38 84 | 39 85 | 40 86 | 41 87 | 42 88 | 43 89 | 44 90 | 45 91 | 46 92 | 47 93 | 48 94 | 49 95 | 50 96 | 51 97 | 52 98 | 53 99 | 54 100 | 55 101 | 56 102 | 57 103 | 58 104 | 59 105 | 60 106 | 61 107 | 62 108 | 63 109 | 64 110 | 65 111 | 66 112 | 67 113 | 68 114 | 69 115 | 70 116 | 71 117 | 72 118 | 73 119 | 74 120 | 75 121 | 76  122 |   123 |   124 |   125 |   126 |   127 |   128 |   129 |   130 |   131 |   132 |   133 |   134 |   135 |   136 |   137 | 138 |   139 |   140 |   141 |   142 |   143 |   144 |   145 |   146 |   147 |   148 |   149 |   150 |   151 |   152 |   153 |   154 |   155 |   156 |   157 |   158 |   159 |   160 |   161 |   162 |   163 |   164 |   165 |   166 |   167 |   168 |   169 |   170 |   171 |   172 |   173 |   174 |   175 |   176 |   177 |   178 |   179 |   180 |   181 |   182 |   183 |   184 |   185 |   186 |   187 |   188 |   189 |   190 |   191 |   192 |   193 |   194 |   195 |   196 |  
// <template>
197 | //   <input type="file" name="fileUpload" @change="onFileChange">
198 | // </template>
199 | //
200 | // <script type="text/babel">
201 | export default {
202 |   name: 'fileupload',
203 |   props: {
204 |     target: {
205 |       type: String
206 |     },
207 |     action: {
208 |       type: String
209 |     }
210 |   },
211 |   data () {
212 |     return {
213 |       file: null
214 |     }
215 |   },
216 |   methods: {
217 |     emitter (event, data) {
218 |       this.$emit(event, data)
219 |     },
220 |     updateProgress (oEvent) {
221 |       let vm = this
222 |       if (oEvent.lengthComputable) {
223 |         let percentComplete = Math.round(oEvent.loaded * 100 / oEvent.total)
224 |         vm.emitter('progress', percentComplete)
225 |       } else {
226 |         // Unable to compute progress information since the total size is unknown
227 |         vm.emitter('progress', false)
228 |       }
229 |     },
230 |     onFileChange (e) {
231 |       let vm = this
232 |  
233 |       if (!this.target || this.target === '') {
234 |         console.log('Please provide the target url')
235 |       } else if (!this.action || this.action === '') {
236 |         console.log('Please provide file upload action ( POST / PUT )')
237 |       } else if (this.action !== 'POST' && this.action !== 'PUT') {
238 |         console.log('File upload component only allows POST and PUT Actions')
239 |       } else {
240 |         let files = e.target.files || e.dataTransfer.files
241 |  
242 |         if (!files.length) {
243 |           return
244 |         };
245 |  
246 |         /*global FormData XMLHttpRequest:true*/
247 |         /*eslint no-undef: "error"*/
248 |  
249 |         this.file = files[0]
250 |         let formData = new FormData()
251 |         formData.append('file', this.file)
252 |  
253 |         var xhr = new XMLHttpRequest()
254 |         xhr.open(this.action, this.target)
255 |  
256 |         xhr.onloadstart = function (e) {
257 |           vm.emitter('start', e)
258 |         }
259 |         xhr.onloadend = function (e) {
260 |           vm.emitter('finish', e)
261 |         }
262 |         xhr.upload.onprogress = vm.updateProgress
263 |         xhr.send(formData)
264 |       }
265 |     }
266 |   }
267 | }
268 | // </script>
269 | /* generated by vue-loader */
270 |  
271 |  
273 |
274 |
275 | 279 | 280 | 281 | 288 | 289 | 290 | 291 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/ 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files src/ 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 5/5 26 |
27 |
28 | 100% 29 | Branches 30 | 4/4 31 |
32 |
33 | 100% 34 | Functions 35 | 1/1 36 |
37 |
38 | 100% 39 | Lines 40 | 3/3 41 |
42 |
43 | 1 branch 44 | Ignored      45 |
46 |
47 |
48 |
49 |
50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
FileStatementsBranchesFunctionsLines
index.js
100%5/5100%4/4100%1/1100%3/3
80 |
81 |
82 | 86 | 87 | 88 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov-report/src/index.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for src/index.js 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / src/ index.js 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 5/5 26 |
27 |
28 | 100% 29 | Branches 30 | 4/4 31 |
32 |
33 | 100% 34 | Functions 35 | 1/1 36 |
37 |
38 | 100% 39 | Lines 40 | 3/3 41 |
42 |
43 | 1 branch 44 | Ignored      45 |
46 |
47 |
48 |
49 |

50 | 
69 | 
1 51 | 2 52 | 3 53 | 4 54 | 5 55 | 6 56 | 7 57 |   58 | 59 |   60 |   61 |   62 |  
import FileUpload from './FileUpload'
63 |  
64 | module.exports = {
65 |   FileUpload: FileUpload
66 | }
67 |  
68 |  
70 |
71 |
72 | 76 | 77 | 78 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /test/unit/coverage/lcov.info: -------------------------------------------------------------------------------- 1 | TN: 2 | SF:/home/varun/Documents/js/opensource/vuejs/uploadv2/src/index.js 3 | FN:7,_interopRequireDefault 4 | FNF:1 5 | FNH:1 6 | FNDA:1,_interopRequireDefault 7 | DA:0,1 8 | DA:1,1 9 | DA:3,1 10 | LF:3 11 | LH:3 12 | BRDA:7,1,0,0 13 | BRDA:7,1,1,1 14 | BRDA:7,2,0,1 15 | BRDA:7,2,1,1 16 | BRF:4 17 | BRH:4 18 | end_of_record 19 | -------------------------------------------------------------------------------- /test/unit/index.js: -------------------------------------------------------------------------------- 1 | var testsContext = require.context('.', true, /\.spec$/) 2 | testsContext.keys().forEach(testsContext) 3 | -------------------------------------------------------------------------------- /test/unit/karma.conf.js: -------------------------------------------------------------------------------- 1 | var webpackConfig = require('./../../build/webpack.base.conf') 2 | delete webpackConfig.entry 3 | 4 | // karma.conf.js 5 | module.exports = function (config) { 6 | config.set({ 7 | browsers: ['PhantomJS'], 8 | frameworks: ['jasmine'], 9 | // this is the entry file for all our tests. 10 | files: ['index.js'], 11 | // we will pass the entry file to webpack for bundling. 12 | preprocessors: { 13 | 'index.js': ['webpack'] 14 | }, 15 | // use the webpack config 16 | webpack: webpackConfig, 17 | // avoid walls of useless text 18 | webpackMiddleware: { 19 | noInfo: true 20 | }, 21 | singleRun: true 22 | }) 23 | } 24 | -------------------------------------------------------------------------------- /test/unit/specs/FileUpload.spec.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | let Vue = require('vue') 3 | /* eslint-enable */ 4 | let FileUpload = require('../../../src/FileUpload.vue') 5 | 6 | describe('FileUpload.vue', () => { 7 | it('data should return a function', () => { 8 | expect(typeof FileUpload.data).toBe('function') 9 | }) 10 | 11 | it('sets the correct default data', () => { 12 | const defaultData = FileUpload.data() 13 | expect(defaultData.file).toBe(null) 14 | }) 15 | 16 | it('emitter has should be a function', () => { 17 | expect(typeof FileUpload.methods.emitter).toBe('function') 18 | }) 19 | 20 | it('uploadProgress has to be a function', () => { 21 | expect(typeof FileUpload.methods.uploadProgress).toBe('function') 22 | }) 23 | 24 | it('onFileChange has to be a function', () => { 25 | expect(typeof FileUpload.methods.onFileChange).toBe('function') 26 | }) 27 | }) 28 | --------------------------------------------------------------------------------