"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/unit/features/component/component-async.spec.js" between
vue-2.6.9.tar.gz and vue-2.6.10.tar.gz

About: Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

component-async.spec.js  (vue-2.6.9):component-async.spec.js  (vue-2.6.10)
import Vue from 'vue' import Vue from 'vue'
import { Promise } from 'es6-promise' import { Promise } from 'es6-promise'
describe('Component async', () => { describe('Component async', () => {
const oldSetTimeout = window.setTimeout;
const oldClearTimeout = window.clearTimeout;
// will contain pending timeouts set during the test iteration
// will contain the id of the timeout as the key, and the the millisecond time
out as the value
// this helps to identify the timeout that is still pending
let timeoutsPending = {};
beforeEach(function () {
// reset the timeouts for this iteration
timeoutsPending = {};
window.setTimeout = function(func, delay) {
let id = oldSetTimeout(function() {
delete timeoutsPending[id];
func();
}, delay);
timeoutsPending[id] = delay;
return id
};
window.clearTimeout = function(id) {
oldClearTimeout(id);
delete timeoutsPending[id];
};
})
afterEach(function () {
window.setTimeout = oldSetTimeout;
window.clearTimeout = oldClearTimeout;
// after the test is complete no timeouts that have been set up during the t
est should still be active
// compare stringified JSON for better error message containing ID and milli
second timeout
expect(JSON.stringify(timeoutsPending)).toEqual(JSON.stringify({}))
})
it('normal', done => { it('normal', done => {
const vm = new Vue({ const vm = new Vue({
template: '<div><test></test></div>', template: '<div><test></test></div>',
components: { components: {
test: (resolve) => { test: (resolve) => {
setTimeout(() => { setTimeout(() => {
resolve({ resolve({
template: '<div>hi</div>' template: '<div>hi</div>'
}) })
// wait for parent update // wait for parent update
skipping to change at line 346 skipping to change at line 382
} }
}).$mount() }).$mount()
setTimeout(() => { setTimeout(() => {
expect(vm.$el.textContent).toBe('hi') expect(vm.$el.textContent).toBe('hi')
expect(`Failed to resolve async component`).not.toHaveBeenWarned() expect(`Failed to resolve async component`).not.toHaveBeenWarned()
done() done()
}, 50) }, 50)
}) })
it('should not have running timeout/loading if resolved', done => {
const vm = new Vue({
template: `<div><test/></div>`,
components: {
test: () => ({
component: new Promise((resolve, reject) => {
setTimeout(() => {
resolve({ template: '<div>hi</div>' })
Promise.resolve().then(() => {
Vue.nextTick(next)
})
}, 10)
}),
loading: { template: `<div>loading</div>` },
delay: 30,
error: { template: `<div>error</div>` },
timeout: 40
})
}
}).$mount()
function next () {
expect(vm.$el.textContent).toBe('hi')
// the afterEach() will ensure that the timeouts for delay and timeout h
ave been cleared
done()
}
})
// #7107 // #7107
it(`should work when resolving sync in sibling component's mounted hook`, do ne => { it(`should work when resolving sync in sibling component's mounted hook`, do ne => {
let resolveTwo let resolveTwo
const vm = new Vue({ const vm = new Vue({
template: `<div><one/> <two/></div>`, template: `<div><one/> <two/></div>`,
components: { components: {
one: { one: {
template: `<div>one</div>`, template: `<div>one</div>`,
mounted () { mounted () {
 End of changes. 2 change blocks. 
0 lines changed or deleted 68 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)