Skip to content

Commit 1e5174d

Browse files
committed
test: add more test case for watch option
1 parent 8b382b3 commit 1e5174d

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

Diff for: src/core/util/lang.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function def (obj: Object, key: string, val: any, enumerable?: boolean) {
3030
/**
3131
* Parse simple path.
3232
*/
33-
const bailRE = new RegExp(`[^${unicodeLetters}.$_]`)
33+
const bailRE = new RegExp(`[^${unicodeLetters}.$_\\d]`)
3434
export function parsePath (path: string): any {
3535
if (bailRE.test(path)) {
3636
return

Diff for: test/unit/features/component/component-scoped-slot.spec.js

+6
Original file line numberDiff line numberDiff line change
@@ -689,5 +689,11 @@ describe('Component scoped slot', () => {
689689
}).$mount()
690690
expect(vm.$el.innerHTML).toBe(`default<div>default</div><div>static</div>`)
691691
})
692+
693+
it('should not break when template expression uses $slots', () => {
694+
const vm = new Vue({
695+
template: ``
696+
})
697+
})
692698
})
693699
})

Diff for: test/unit/features/options/watch.spec.js

+32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Vue from 'vue'
22
import testObjectOption from '../../../helpers/test-object-option'
3+
import { finished } from 'stream';
34

45
describe('Options watch', () => {
56
let spy
@@ -143,4 +144,35 @@ describe('Options watch', () => {
143144
expect(spy3).toHaveBeenCalledWith(1, 0)
144145
}).then(done)
145146
})
147+
148+
it('should support watching unicode paths', done => {
149+
const vm = new Vue({
150+
data: {
151+
数据: 1
152+
},
153+
watch: {
154+
数据: spy
155+
}
156+
})
157+
expect(spy).not.toHaveBeenCalled()
158+
vm['数据'] = 2
159+
expect(spy).not.toHaveBeenCalled()
160+
waitForUpdate(() => {
161+
expect(spy).toHaveBeenCalledWith(2, 1)
162+
}).then(done)
163+
})
164+
165+
it('should not warn proper usage', () => {
166+
const vm = new Vue({
167+
data: {
168+
foo: { _bar: 1 }, // element has such watchers...
169+
prop1: 123
170+
},
171+
watch: {
172+
'foo._bar': () => {},
173+
prop1 () {}
174+
}
175+
})
176+
expect(`Failed watching path`).not.toHaveBeenWarned()
177+
})
146178
})

0 commit comments

Comments
 (0)