Hunter
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
50 additions and
0 deletions
-
packages/runtime-core/__tests__/apiOptions.spec.ts
|
|
@ -888,6 +888,56 @@ describe('api: options', () => { |
|
|
|
expect(watchSpy.mock.calls[0].slice(0, 2)).toEqual(['hello', 'mixin3']) |
|
|
|
}) |
|
|
|
|
|
|
|
test('injection from closest ancestor', () => { |
|
|
|
const Root = defineComponent({ |
|
|
|
provide: { |
|
|
|
a: 'root' |
|
|
|
}, |
|
|
|
render() { |
|
|
|
return [h(Mid), ' ', h(MidWithProvide), ' ', h(MidWithMixinProvide)] |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
const Mid = { |
|
|
|
render() { |
|
|
|
return h(Child) |
|
|
|
} |
|
|
|
} as any |
|
|
|
|
|
|
|
const MidWithProvide = { |
|
|
|
provide: { |
|
|
|
a: 'midWithProvide' |
|
|
|
}, |
|
|
|
render() { |
|
|
|
return h(Child) |
|
|
|
} |
|
|
|
} as any |
|
|
|
|
|
|
|
const mixin = { |
|
|
|
provide: { |
|
|
|
a: 'midWithMixinProvide' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const MidWithMixinProvide = { |
|
|
|
mixins: [mixin], |
|
|
|
render() { |
|
|
|
return h(Child) |
|
|
|
} |
|
|
|
} as any |
|
|
|
|
|
|
|
const Child = { |
|
|
|
inject: ['a'], |
|
|
|
render() { |
|
|
|
return this.a |
|
|
|
} |
|
|
|
} as any |
|
|
|
|
|
|
|
expect(renderToString(h(Root))).toBe( |
|
|
|
'root midWithProvide midWithMixinProvide' |
|
|
|
) |
|
|
|
}) |
|
|
|
|
|
|
|
describe('warnings', () => { |
|
|
|
test('Expected a function as watch handler', () => { |
|
|
|
const Comp = { |
|
|
|