|
@@ -324,4 +324,98 @@ describe('component: slots', () => {
|
|
|
'Slot "default" invoked outside of the render function',
|
|
'Slot "default" invoked outside of the render function',
|
|
|
).not.toHaveBeenWarned()
|
|
).not.toHaveBeenWarned()
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ test('basic warn', () => {
|
|
|
|
|
+ const Comp = {
|
|
|
|
|
+ setup(_: any, { slots }: any) {
|
|
|
|
|
+ slots.default && slots.default()
|
|
|
|
|
+ return () => null
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const App = {
|
|
|
|
|
+ setup() {
|
|
|
|
|
+ return () => h(Comp, () => h('div'))
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ createApp(App).mount(nodeOps.createElement('div'))
|
|
|
|
|
+ expect(
|
|
|
|
|
+ 'Slot "default" invoked outside of the render function',
|
|
|
|
|
+ ).toHaveBeenWarned()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ test('basic warn when mounting another app in setup', () => {
|
|
|
|
|
+ const Comp = {
|
|
|
|
|
+ setup(_: any, { slots }: any) {
|
|
|
|
|
+ slots.default?.()
|
|
|
|
|
+ return () => null
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const mountComp = () => {
|
|
|
|
|
+ createApp({
|
|
|
|
|
+ setup() {
|
|
|
|
|
+ return () => h(Comp, () => 'msg')
|
|
|
|
|
+ },
|
|
|
|
|
+ }).mount(nodeOps.createElement('div'))
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const App = {
|
|
|
|
|
+ setup() {
|
|
|
|
|
+ mountComp()
|
|
|
|
|
+ return () => null
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ createApp(App).mount(nodeOps.createElement('div'))
|
|
|
|
|
+ expect(
|
|
|
|
|
+ 'Slot "default" invoked outside of the render function',
|
|
|
|
|
+ ).toHaveBeenWarned()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ test('should not warn when render in setup', () => {
|
|
|
|
|
+ const container = {
|
|
|
|
|
+ setup(_: any, { slots }: any) {
|
|
|
|
|
+ return () => slots.default && slots.default()
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const comp = h(container, null, () => h('div'))
|
|
|
|
|
+
|
|
|
|
|
+ const App = {
|
|
|
|
|
+ setup() {
|
|
|
|
|
+ render(h(comp), nodeOps.createElement('div'))
|
|
|
|
|
+ return () => null
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ createApp(App).mount(nodeOps.createElement('div'))
|
|
|
|
|
+ expect(
|
|
|
|
|
+ 'Slot "default" invoked outside of the render function',
|
|
|
|
|
+ ).not.toHaveBeenWarned()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ test('basic warn when render in setup', () => {
|
|
|
|
|
+ const container = {
|
|
|
|
|
+ setup(_: any, { slots }: any) {
|
|
|
|
|
+ slots.default && slots.default()
|
|
|
|
|
+ return () => null
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const comp = h(container, null, () => h('div'))
|
|
|
|
|
+
|
|
|
|
|
+ const App = {
|
|
|
|
|
+ setup() {
|
|
|
|
|
+ render(h(comp), nodeOps.createElement('div'))
|
|
|
|
|
+ return () => null
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ createApp(App).mount(nodeOps.createElement('div'))
|
|
|
|
|
+ expect(
|
|
|
|
|
+ 'Slot "default" invoked outside of the render function',
|
|
|
|
|
+ ).toHaveBeenWarned()
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|