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