-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
支持transition-group/activate测试用例 (#45)
* 支持transition-group/activate测试用例 * 支持transition-group/activate测试用例 * 支持transition-group/activate测试用例 Co-authored-by: donghualei <[email protected]>
- Loading branch information
1 parent
3d5d768
commit a98f420
Showing
16 changed files
with
1,179 additions
and
811 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* eslint-disable no-undef */ | ||
|
||
import Vue from '../../../helpers/vue'; | ||
|
||
describe('activated and deactivated', () => { | ||
it('works', done => { | ||
|
||
const activatedSpy = jasmine.createSpy(); | ||
const deactivatedSpy = jasmine.createSpy(); | ||
const childDeactivatedSpy = jasmine.createSpy(); | ||
const child2ActivatedSpy = jasmine.createSpy(); | ||
const vm = new Vue({ | ||
template: ` | ||
<div> | ||
<child1></child1> | ||
<child2></child2> | ||
</div> | ||
`, | ||
components: { | ||
child1: { | ||
data() {}, | ||
template: '<div>child1</div>', | ||
deactivated: childDeactivatedSpy, | ||
}, | ||
child2: { | ||
data() {}, | ||
template: '<div>child2</div>', | ||
activated: child2ActivatedSpy, | ||
}, | ||
}, | ||
activated: activatedSpy, | ||
deactivated: deactivatedSpy, | ||
}).$mount(); | ||
vm.$deactivate(true); | ||
waitForUpdate(() => { | ||
expect(deactivatedSpy).toHaveBeenCalled(); | ||
expect(childDeactivatedSpy).toHaveBeenCalled(); | ||
vm.$activate(true); | ||
}).then(() => { | ||
expect(activatedSpy).toHaveBeenCalled(); | ||
expect(child2ActivatedSpy).toHaveBeenCalled(); | ||
}).then(done); | ||
}); | ||
|
||
it('activated child and parent', done => { | ||
const activatedSpy = jasmine.createSpy(); | ||
const deactivatedSpy = jasmine.createSpy(); | ||
const childDeactivatedSpy = jasmine.createSpy(); | ||
const childActivatedSpy = jasmine.createSpy(); | ||
|
||
const vm = new Vue({ | ||
template: ` | ||
<div> | ||
<child1></child1> | ||
</div> | ||
`, | ||
components: { | ||
child1: { | ||
data() {}, | ||
template: '<div>child1</div>', | ||
deactivated: childDeactivatedSpy, | ||
activated: childActivatedSpy, | ||
}, | ||
}, | ||
activated: activatedSpy, | ||
deactivated: deactivatedSpy, | ||
}).$mount(); | ||
vm.$deactivate(true); | ||
vm.$children[0].$deactivate(true); | ||
waitForUpdate(() => { | ||
expect(childDeactivatedSpy).toHaveBeenCalled(); | ||
expect(childDeactivatedSpy.calls.count()).toBe(1); | ||
vm.$deactivate(true); | ||
}).then(() => { | ||
expect(childDeactivatedSpy.calls.count()).toBe(1); | ||
vm.$activate(true); | ||
}).then(() => { | ||
vm.$children[0].$activate(true); | ||
}).then(() => { | ||
expect(childActivatedSpy.calls.count()).toBe(1); | ||
expect(activatedSpy.calls.count()).toBe(1); | ||
}).then(done); | ||
}); | ||
|
||
it('activated child and parent', done => { | ||
const activatedSpy = jasmine.createSpy(); | ||
const deactivatedSpy = jasmine.createSpy(); | ||
const childDeactivatedSpy = jasmine.createSpy(); | ||
const childActivatedSpy = jasmine.createSpy(); | ||
|
||
const vm = new Vue({ | ||
template: ` | ||
<div> | ||
<child1></child1> | ||
</div> | ||
`, | ||
components: { | ||
child1: { | ||
data() {}, | ||
template: '<div>child1</div>', | ||
deactivated: childDeactivatedSpy, | ||
activated: childActivatedSpy, | ||
}, | ||
}, | ||
activated: activatedSpy, | ||
deactivated: deactivatedSpy, | ||
}).$mount(); | ||
vm.$activate(true); | ||
vm.$children[0].$activate(true); | ||
waitForUpdate(() => { | ||
expect(activatedSpy).toHaveBeenCalled(); | ||
expect(activatedSpy.calls.count()).toBe(1); | ||
vm.$deactivate(true); | ||
}).then(() => { | ||
expect(deactivatedSpy.calls.count()).toBe(1); | ||
expect(childDeactivatedSpy.calls.count()).toBe(1); | ||
vm.$children[0].$activate(true); | ||
}).then(() => { | ||
expect(activatedSpy.calls.count()).toBe(1); | ||
}).then(done); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* eslint-disable no-undef */ | ||
import Vue from '../../../helpers/vue'; | ||
|
||
|
||
describe('global-api methods and filters', () => { | ||
|
||
it('methods', done => { | ||
const vm = new Vue({ | ||
template: '<div><span :test="foo">hello</span></div>', | ||
data: { | ||
foo: ['hello', 'world'], | ||
str: 'hello world', | ||
arr: ['a', 'b', 'c', 'd', 'e'], | ||
num: 1.1, | ||
}, | ||
computed: { | ||
b() { | ||
return this.array_join(this.foo, '-'); | ||
}, | ||
c() { | ||
return this.str_pos(this.str, 'e'); | ||
}, | ||
d() { | ||
return this.array_slice(this.arr, 0, 2); | ||
}, | ||
e() { | ||
return this.math_floor(this.num); | ||
}, | ||
}, | ||
}).$mount(); | ||
|
||
expect(vm.b).toBe('hello-world'); | ||
expect(vm.c).toBe(1); | ||
expect(vm.d).toEqual(['a', 'b']); | ||
expect(vm.e).toBe(1); | ||
done(); | ||
}); | ||
|
||
|
||
it('filters', done => { | ||
const vm = new Vue({ | ||
template: '<div :test="foo | json"><span>hello</span></div>', | ||
data: { | ||
foo: {a: 1}, | ||
}, | ||
}).$mount(); | ||
|
||
|
||
expect(vm.$el.getAttribute('test')).toBe('{"a":1}'); | ||
waitForUpdate(() => { | ||
|
||
}).then(done); | ||
}); | ||
|
||
it('filters lower', done => { | ||
const vm = new Vue({ | ||
template: '<div>{{"HELLO" | lower}}</div>', | ||
data: { | ||
foo: {a: 1}, | ||
}, | ||
}).$mount(); | ||
|
||
expect(vm.$el.textContent).toBe('hello'); | ||
done(); | ||
}); | ||
|
||
it('filters lower', done => { | ||
const vm = new Vue({ | ||
template: '<div>{{"hello" | upper}}</div>', | ||
data: { | ||
foo: {a: 1}, | ||
}, | ||
}).$mount(); | ||
|
||
expect(vm.$el.textContent).toBe('HELLO'); | ||
done(); | ||
}); | ||
|
||
// it('filters _s', done => { | ||
// const vm = new Vue({ | ||
// template: '<div>{{foo | _s}}</div>', | ||
// data: { | ||
// foo: {a: 1}, | ||
// }, | ||
// }).$mount(); | ||
// expect(vm.$el.textContent).toBe('{"a":1}'); | ||
// done(); | ||
// }); | ||
}); |
Oops, something went wrong.