@@ -1,5 +1,5 @@
|
||||
import { baseCompile } from '../src/compile'
|
||||
import { SET_SCOPE_ID } from '../src/runtimeHelpers'
|
||||
import { PUSH_SCOPE_ID, POP_SCOPE_ID } from '../src/runtimeHelpers'
|
||||
import { PatchFlags } from '@vue/shared'
|
||||
import { genFlagText } from './testUtils'
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('scopeId compiler support', () => {
|
||||
mode: 'module',
|
||||
scopeId: 'test'
|
||||
})
|
||||
expect(code).toMatch(`default: _withCtx(() => [`)
|
||||
expect(code).toMatch(`default: _withId(() => [`)
|
||||
expect(code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
@@ -36,8 +36,8 @@ describe('scopeId compiler support', () => {
|
||||
scopeId: 'test'
|
||||
}
|
||||
)
|
||||
expect(code).toMatch(`foo: _withCtx(({ msg }) => [`)
|
||||
expect(code).toMatch(`bar: _withCtx(() => [`)
|
||||
expect(code).toMatch(`foo: _withId(({ msg }) => [`)
|
||||
expect(code).toMatch(`bar: _withId(() => [`)
|
||||
expect(code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
@@ -53,8 +53,8 @@ describe('scopeId compiler support', () => {
|
||||
scopeId: 'test'
|
||||
}
|
||||
)
|
||||
expect(code).toMatch(/name: "foo",\s+fn: _withCtx\(/)
|
||||
expect(code).toMatch(/name: i,\s+fn: _withCtx\(/)
|
||||
expect(code).toMatch(/name: "foo",\s+fn: _withId\(/)
|
||||
expect(code).toMatch(/name: i,\s+fn: _withId\(/)
|
||||
expect(code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
@@ -67,18 +67,19 @@ describe('scopeId compiler support', () => {
|
||||
hoistStatic: true
|
||||
}
|
||||
)
|
||||
expect(ast.helpers).toContain(SET_SCOPE_ID)
|
||||
expect(ast.helpers).toContain(PUSH_SCOPE_ID)
|
||||
expect(ast.helpers).toContain(POP_SCOPE_ID)
|
||||
expect(ast.hoists.length).toBe(2)
|
||||
expect(code).toMatch(
|
||||
[
|
||||
`_setScopeId("test")`,
|
||||
`_pushScopeId("test")`,
|
||||
`const _hoisted_1 = /*#__PURE__*/_createVNode("div", null, "hello", ${genFlagText(
|
||||
PatchFlags.HOISTED
|
||||
)})`,
|
||||
`const _hoisted_2 = /*#__PURE__*/_createVNode("div", null, "world", ${genFlagText(
|
||||
PatchFlags.HOISTED
|
||||
)})`,
|
||||
`_setScopeId(null)`
|
||||
`_popScopeId()`
|
||||
].join('\n')
|
||||
)
|
||||
expect(code).toMatchSnapshot()
|
||||
|
||||
Reference in New Issue
Block a user