Skip to content

Commit 7b06945

Browse files
committed
fix Object.prototype.watch test case
1 parent 48c0c1c commit 7b06945

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

test/unit/features/options/extends.spec.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,22 @@ describe('Options extends', () => {
4646
expect(vm.b).toBe(2)
4747
expect(vm.c).toBe(3)
4848
})
49-
})
5049

51-
describe('Options extends with Object.prototype.watch', () => {
52-
beforeAll(function () {
50+
it('should work with global mixins + Object.prototype.watch', done => {
51+
let fakeWatch = false
5352
if (!Object.prototype.watch) {
53+
fakeWatch = true
5454
// eslint-disable-next-line no-extend-native
55-
Object.prototype.watch = {
56-
remove: true
57-
}
58-
}
59-
})
60-
afterAll(function () {
61-
if (Object.prototype.watch && Object.prototype.watch.remove) {
62-
delete Object.prototype.watch
55+
Object.defineProperty(Object.prototype, 'watch', {
56+
writable: true,
57+
configurable: true,
58+
enumerable: false,
59+
value: () => {}
60+
})
6361
}
64-
})
65-
it('should work with global mixins', done => {
66-
Vue.use({
67-
install: function () {
68-
Vue.mixin({})
69-
}
70-
})
62+
63+
Vue.mixin({})
64+
7165
const spy = jasmine.createSpy('watch')
7266
const A = Vue.extend({
7367
data: function () {
@@ -85,6 +79,10 @@ describe('Options extends with Object.prototype.watch', () => {
8579
})
8680
waitForUpdate(() => {
8781
expect(spy).toHaveBeenCalledWith(2, 1)
82+
83+
if (fakeWatch) {
84+
delete Object.prototype.watch
85+
}
8886
}).then(done)
8987
})
9088
})

0 commit comments

Comments
 (0)