test: fix vbind tests
This commit is contained in:
parent
6059fe69e8
commit
caccf92721
@ -4,7 +4,8 @@ import {
|
||||
ElementNode,
|
||||
ObjectExpression,
|
||||
CompilerOptions,
|
||||
ErrorCodes
|
||||
ErrorCodes,
|
||||
CallExpression
|
||||
} from '../../src'
|
||||
import { transformBind } from '../../src/transforms/vBind'
|
||||
import { transformElement } from '../../src/transforms/transformElement'
|
||||
@ -32,7 +33,8 @@ function parseWithVBind(
|
||||
describe('compiler: transform v-bind', () => {
|
||||
test('basic', () => {
|
||||
const node = parseWithVBind(`<div v-bind:id="id"/>`)
|
||||
const props = node.codegenNode!.arguments[1] as ObjectExpression
|
||||
const props = (node.codegenNode as CallExpression)
|
||||
.arguments[1] as ObjectExpression
|
||||
expect(props.properties[0]).toMatchObject({
|
||||
key: {
|
||||
content: `id`,
|
||||
@ -67,7 +69,8 @@ describe('compiler: transform v-bind', () => {
|
||||
|
||||
test('dynamic arg', () => {
|
||||
const node = parseWithVBind(`<div v-bind:[id]="id"/>`)
|
||||
const props = node.codegenNode!.arguments[1] as ObjectExpression
|
||||
const props = (node.codegenNode as CallExpression)
|
||||
.arguments[1] as ObjectExpression
|
||||
expect(props.properties[0]).toMatchObject({
|
||||
key: {
|
||||
content: `id`,
|
||||
@ -100,7 +103,8 @@ describe('compiler: transform v-bind', () => {
|
||||
|
||||
test('.camel modifier', () => {
|
||||
const node = parseWithVBind(`<div v-bind:foo-bar.camel="id"/>`)
|
||||
const props = node.codegenNode!.arguments[1] as ObjectExpression
|
||||
const props = (node.codegenNode as CallExpression)
|
||||
.arguments[1] as ObjectExpression
|
||||
expect(props.properties[0]).toMatchObject({
|
||||
key: {
|
||||
content: `fooBar`,
|
||||
@ -115,7 +119,8 @@ describe('compiler: transform v-bind', () => {
|
||||
|
||||
test('.camel modifier w/ dynamic arg', () => {
|
||||
const node = parseWithVBind(`<div v-bind:[foo].camel="id"/>`)
|
||||
const props = node.codegenNode!.arguments[1] as ObjectExpression
|
||||
const props = (node.codegenNode as CallExpression)
|
||||
.arguments[1] as ObjectExpression
|
||||
expect(props.properties[0]).toMatchObject({
|
||||
key: {
|
||||
content: `_${CAMELIZE}(foo)`,
|
||||
@ -132,7 +137,8 @@ describe('compiler: transform v-bind', () => {
|
||||
const node = parseWithVBind(`<div v-bind:[foo(bar)].camel="id"/>`, {
|
||||
prefixIdentifiers: true
|
||||
})
|
||||
const props = node.codegenNode!.arguments[1] as ObjectExpression
|
||||
const props = (node.codegenNode as CallExpression)
|
||||
.arguments[1] as ObjectExpression
|
||||
expect(props.properties[0]).toMatchObject({
|
||||
key: {
|
||||
children: [
|
||||
|
Loading…
Reference in New Issue
Block a user