diff --git a/example/index.js b/example/index.js index c3d8156..db78e46 100644 --- a/example/index.js +++ b/example/index.js @@ -1,7 +1,8 @@ -import Vue from 'vue'; -import App from './App'; +import Vue from 'vue' +import App from './App' +// eslint-disable-next-line new Vue({ el: '#app', render: h => h(App), -}); +}) diff --git a/src/index.js b/src/index.js index 2282dda..be79683 100644 --- a/src/index.js +++ b/src/index.js @@ -11,56 +11,56 @@ export default { error: null, }), - render(h) { + render (h) { if (this.error instanceof Error || (this.error && this.error.length)) { - return this.$scopedSlots.error(this.error); + return this.$scopedSlots.error(this.error) } else if (this.resolved) { - return this.$scopedSlots.default(this.data); + return this.$scopedSlots.default(this.data) } else { - return this.$slots.default[0]; + return this.$slots.default[0] } }, watch: { promise: { - handler(promise) { - if (!promise) return; - this.resolved = false; - this.error = null; + handler (promise) { + if (!promise) return + this.resolved = false + this.error = null promise .then(data => { if (this.promise === promise) { - this.resolved = true; - this.data = data; + this.resolved = true + this.data = data } }) .catch(err => { - if (this.promise === promise) this.error = err; - }); + if (this.promise === promise) this.error = err + }) }, immediate: true, }, promises: { - handler(promises) { - if (!promises) return; - this.resolved = false; - this.error = []; - this.data = []; + handler (promises) { + if (!promises) return + this.resolved = false + this.error = [] + this.data = [] promises.forEach(p => { p .then(data => { if (this.promises === promises) { - this.resolved = true; - this.data.push(data); + this.resolved = true + this.data.push(data) } }) .catch(err => { - if (this.promises === promises) this.error.push(err); - }); - }); + if (this.promises === promises) this.error.push(err) + }) + }) }, immediate: true, }, }, -}; +} diff --git a/test/index.spec.js b/test/index.spec.js index e8ba77e..65c5029 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -1,8 +1,7 @@ import { mount } from '@vue/test-utils' -import Promised from '../src' import Helper from './utils/Helper' -const tick = () => new Promise(r => setImmediate(r)) +const tick = () => new Promise(resolve => setImmediate(resolve)) describe('Tweezing', () => { let wrapper