test: fix tests
This commit is contained in:
parent
baa8954884
commit
3f05315d17
File diff suppressed because it is too large
Load Diff
@ -211,9 +211,9 @@ describe('compiler: parse', () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
const element = ast.children[0] as ElementNode
|
const element = ast.children[0] as ElementNode
|
||||||
const text1 = (element.attrs[0] as AttributeNode).value
|
const text1 = (element.props[0] as AttributeNode).value
|
||||||
const text2 = (element.attrs[1] as AttributeNode).value
|
const text2 = (element.props[1] as AttributeNode).value
|
||||||
const text3 = (element.attrs[2] as AttributeNode).value
|
const text3 = (element.props[2] as AttributeNode).value
|
||||||
|
|
||||||
expect(text1).toStrictEqual({
|
expect(text1).toStrictEqual({
|
||||||
type: NodeTypes.TEXT,
|
type: NodeTypes.TEXT,
|
||||||
@ -426,8 +426,8 @@ describe('compiler: parse', () => {
|
|||||||
ns: Namespaces.HTML,
|
ns: Namespaces.HTML,
|
||||||
tag: 'div',
|
tag: 'div',
|
||||||
tagType: ElementTypes.ELEMENT,
|
tagType: ElementTypes.ELEMENT,
|
||||||
attrs: [],
|
codegenNode: undefined,
|
||||||
directives: [],
|
props: [],
|
||||||
isSelfClosing: false,
|
isSelfClosing: false,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
@ -458,8 +458,9 @@ describe('compiler: parse', () => {
|
|||||||
ns: Namespaces.HTML,
|
ns: Namespaces.HTML,
|
||||||
tag: 'div',
|
tag: 'div',
|
||||||
tagType: ElementTypes.ELEMENT,
|
tagType: ElementTypes.ELEMENT,
|
||||||
attrs: [],
|
codegenNode: undefined,
|
||||||
directives: [],
|
props: [],
|
||||||
|
|
||||||
isSelfClosing: false,
|
isSelfClosing: false,
|
||||||
children: [],
|
children: [],
|
||||||
loc: {
|
loc: {
|
||||||
@ -479,8 +480,9 @@ describe('compiler: parse', () => {
|
|||||||
ns: Namespaces.HTML,
|
ns: Namespaces.HTML,
|
||||||
tag: 'div',
|
tag: 'div',
|
||||||
tagType: ElementTypes.ELEMENT,
|
tagType: ElementTypes.ELEMENT,
|
||||||
attrs: [],
|
codegenNode: undefined,
|
||||||
directives: [],
|
props: [],
|
||||||
|
|
||||||
isSelfClosing: true,
|
isSelfClosing: true,
|
||||||
children: [],
|
children: [],
|
||||||
loc: {
|
loc: {
|
||||||
@ -502,8 +504,9 @@ describe('compiler: parse', () => {
|
|||||||
ns: Namespaces.HTML,
|
ns: Namespaces.HTML,
|
||||||
tag: 'img',
|
tag: 'img',
|
||||||
tagType: ElementTypes.ELEMENT,
|
tagType: ElementTypes.ELEMENT,
|
||||||
attrs: [],
|
codegenNode: undefined,
|
||||||
directives: [],
|
props: [],
|
||||||
|
|
||||||
isSelfClosing: false,
|
isSelfClosing: false,
|
||||||
children: [],
|
children: [],
|
||||||
loc: {
|
loc: {
|
||||||
@ -523,7 +526,8 @@ describe('compiler: parse', () => {
|
|||||||
ns: Namespaces.HTML,
|
ns: Namespaces.HTML,
|
||||||
tag: 'div',
|
tag: 'div',
|
||||||
tagType: ElementTypes.ELEMENT,
|
tagType: ElementTypes.ELEMENT,
|
||||||
attrs: [
|
codegenNode: undefined,
|
||||||
|
props: [
|
||||||
{
|
{
|
||||||
type: NodeTypes.ATTRIBUTE,
|
type: NodeTypes.ATTRIBUTE,
|
||||||
name: 'id',
|
name: 'id',
|
||||||
@ -535,7 +539,7 @@ describe('compiler: parse', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
directives: [],
|
|
||||||
isSelfClosing: false,
|
isSelfClosing: false,
|
||||||
children: [],
|
children: [],
|
||||||
loc: {
|
loc: {
|
||||||
@ -555,7 +559,8 @@ describe('compiler: parse', () => {
|
|||||||
ns: Namespaces.HTML,
|
ns: Namespaces.HTML,
|
||||||
tag: 'div',
|
tag: 'div',
|
||||||
tagType: ElementTypes.ELEMENT,
|
tagType: ElementTypes.ELEMENT,
|
||||||
attrs: [
|
codegenNode: undefined,
|
||||||
|
props: [
|
||||||
{
|
{
|
||||||
type: NodeTypes.ATTRIBUTE,
|
type: NodeTypes.ATTRIBUTE,
|
||||||
name: 'id',
|
name: 'id',
|
||||||
@ -576,7 +581,7 @@ describe('compiler: parse', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
directives: [],
|
|
||||||
isSelfClosing: false,
|
isSelfClosing: false,
|
||||||
children: [],
|
children: [],
|
||||||
loc: {
|
loc: {
|
||||||
@ -596,7 +601,8 @@ describe('compiler: parse', () => {
|
|||||||
ns: Namespaces.HTML,
|
ns: Namespaces.HTML,
|
||||||
tag: 'div',
|
tag: 'div',
|
||||||
tagType: ElementTypes.ELEMENT,
|
tagType: ElementTypes.ELEMENT,
|
||||||
attrs: [
|
codegenNode: undefined,
|
||||||
|
props: [
|
||||||
{
|
{
|
||||||
type: NodeTypes.ATTRIBUTE,
|
type: NodeTypes.ATTRIBUTE,
|
||||||
name: 'id',
|
name: 'id',
|
||||||
@ -617,7 +623,7 @@ describe('compiler: parse', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
directives: [],
|
|
||||||
isSelfClosing: false,
|
isSelfClosing: false,
|
||||||
children: [],
|
children: [],
|
||||||
loc: {
|
loc: {
|
||||||
@ -637,7 +643,8 @@ describe('compiler: parse', () => {
|
|||||||
ns: Namespaces.HTML,
|
ns: Namespaces.HTML,
|
||||||
tag: 'div',
|
tag: 'div',
|
||||||
tagType: ElementTypes.ELEMENT,
|
tagType: ElementTypes.ELEMENT,
|
||||||
attrs: [
|
codegenNode: undefined,
|
||||||
|
props: [
|
||||||
{
|
{
|
||||||
type: NodeTypes.ATTRIBUTE,
|
type: NodeTypes.ATTRIBUTE,
|
||||||
name: 'id',
|
name: 'id',
|
||||||
@ -658,7 +665,7 @@ describe('compiler: parse', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
directives: [],
|
|
||||||
isSelfClosing: false,
|
isSelfClosing: false,
|
||||||
children: [],
|
children: [],
|
||||||
loc: {
|
loc: {
|
||||||
@ -678,7 +685,8 @@ describe('compiler: parse', () => {
|
|||||||
ns: Namespaces.HTML,
|
ns: Namespaces.HTML,
|
||||||
tag: 'div',
|
tag: 'div',
|
||||||
tagType: ElementTypes.ELEMENT,
|
tagType: ElementTypes.ELEMENT,
|
||||||
attrs: [
|
codegenNode: undefined,
|
||||||
|
props: [
|
||||||
{
|
{
|
||||||
type: NodeTypes.ATTRIBUTE,
|
type: NodeTypes.ATTRIBUTE,
|
||||||
name: 'id',
|
name: 'id',
|
||||||
@ -699,7 +707,7 @@ describe('compiler: parse', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
directives: [],
|
|
||||||
isSelfClosing: false,
|
isSelfClosing: false,
|
||||||
children: [],
|
children: [],
|
||||||
loc: {
|
loc: {
|
||||||
@ -719,7 +727,8 @@ describe('compiler: parse', () => {
|
|||||||
ns: Namespaces.HTML,
|
ns: Namespaces.HTML,
|
||||||
tag: 'div',
|
tag: 'div',
|
||||||
tagType: ElementTypes.ELEMENT,
|
tagType: ElementTypes.ELEMENT,
|
||||||
attrs: [
|
codegenNode: undefined,
|
||||||
|
props: [
|
||||||
{
|
{
|
||||||
type: NodeTypes.ATTRIBUTE,
|
type: NodeTypes.ATTRIBUTE,
|
||||||
name: 'id',
|
name: 'id',
|
||||||
@ -740,7 +749,7 @@ describe('compiler: parse', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
directives: [],
|
|
||||||
isSelfClosing: false,
|
isSelfClosing: false,
|
||||||
children: [],
|
children: [],
|
||||||
loc: {
|
loc: {
|
||||||
@ -760,7 +769,8 @@ describe('compiler: parse', () => {
|
|||||||
ns: Namespaces.HTML,
|
ns: Namespaces.HTML,
|
||||||
tag: 'div',
|
tag: 'div',
|
||||||
tagType: ElementTypes.ELEMENT,
|
tagType: ElementTypes.ELEMENT,
|
||||||
attrs: [
|
codegenNode: undefined,
|
||||||
|
props: [
|
||||||
{
|
{
|
||||||
type: NodeTypes.ATTRIBUTE,
|
type: NodeTypes.ATTRIBUTE,
|
||||||
name: 'id',
|
name: 'id',
|
||||||
@ -829,7 +839,7 @@ describe('compiler: parse', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
directives: [],
|
|
||||||
isSelfClosing: false,
|
isSelfClosing: false,
|
||||||
children: [],
|
children: [],
|
||||||
loc: {
|
loc: {
|
||||||
@ -842,7 +852,7 @@ describe('compiler: parse', () => {
|
|||||||
|
|
||||||
test('directive with no value', () => {
|
test('directive with no value', () => {
|
||||||
const ast = parse('<div v-if/>')
|
const ast = parse('<div v-if/>')
|
||||||
const directive = (ast.children[0] as ElementNode).directives[0]
|
const directive = (ast.children[0] as ElementNode).props[0]
|
||||||
|
|
||||||
expect(directive).toStrictEqual({
|
expect(directive).toStrictEqual({
|
||||||
type: NodeTypes.DIRECTIVE,
|
type: NodeTypes.DIRECTIVE,
|
||||||
@ -860,7 +870,7 @@ describe('compiler: parse', () => {
|
|||||||
|
|
||||||
test('directive with value', () => {
|
test('directive with value', () => {
|
||||||
const ast = parse('<div v-if="a"/>')
|
const ast = parse('<div v-if="a"/>')
|
||||||
const directive = (ast.children[0] as ElementNode).directives[0]
|
const directive = (ast.children[0] as ElementNode).props[0]
|
||||||
|
|
||||||
expect(directive).toStrictEqual({
|
expect(directive).toStrictEqual({
|
||||||
type: NodeTypes.DIRECTIVE,
|
type: NodeTypes.DIRECTIVE,
|
||||||
@ -887,7 +897,7 @@ describe('compiler: parse', () => {
|
|||||||
|
|
||||||
test('directive with argument', () => {
|
test('directive with argument', () => {
|
||||||
const ast = parse('<div v-on:click/>')
|
const ast = parse('<div v-on:click/>')
|
||||||
const directive = (ast.children[0] as ElementNode).directives[0]
|
const directive = (ast.children[0] as ElementNode).props[0]
|
||||||
|
|
||||||
expect(directive).toStrictEqual({
|
expect(directive).toStrictEqual({
|
||||||
type: NodeTypes.DIRECTIVE,
|
type: NodeTypes.DIRECTIVE,
|
||||||
@ -922,7 +932,7 @@ describe('compiler: parse', () => {
|
|||||||
|
|
||||||
test('directive with a modifier', () => {
|
test('directive with a modifier', () => {
|
||||||
const ast = parse('<div v-on.enter/>')
|
const ast = parse('<div v-on.enter/>')
|
||||||
const directive = (ast.children[0] as ElementNode).directives[0]
|
const directive = (ast.children[0] as ElementNode).props[0]
|
||||||
|
|
||||||
expect(directive).toStrictEqual({
|
expect(directive).toStrictEqual({
|
||||||
type: NodeTypes.DIRECTIVE,
|
type: NodeTypes.DIRECTIVE,
|
||||||
@ -940,7 +950,7 @@ describe('compiler: parse', () => {
|
|||||||
|
|
||||||
test('directive with two modifiers', () => {
|
test('directive with two modifiers', () => {
|
||||||
const ast = parse('<div v-on.enter.exact/>')
|
const ast = parse('<div v-on.enter.exact/>')
|
||||||
const directive = (ast.children[0] as ElementNode).directives[0]
|
const directive = (ast.children[0] as ElementNode).props[0]
|
||||||
|
|
||||||
expect(directive).toStrictEqual({
|
expect(directive).toStrictEqual({
|
||||||
type: NodeTypes.DIRECTIVE,
|
type: NodeTypes.DIRECTIVE,
|
||||||
@ -958,7 +968,7 @@ describe('compiler: parse', () => {
|
|||||||
|
|
||||||
test('directive with argument and modifiers', () => {
|
test('directive with argument and modifiers', () => {
|
||||||
const ast = parse('<div v-on:click.enter.exact/>')
|
const ast = parse('<div v-on:click.enter.exact/>')
|
||||||
const directive = (ast.children[0] as ElementNode).directives[0]
|
const directive = (ast.children[0] as ElementNode).props[0]
|
||||||
|
|
||||||
expect(directive).toStrictEqual({
|
expect(directive).toStrictEqual({
|
||||||
type: NodeTypes.DIRECTIVE,
|
type: NodeTypes.DIRECTIVE,
|
||||||
@ -993,7 +1003,7 @@ describe('compiler: parse', () => {
|
|||||||
|
|
||||||
test('v-bind shorthand', () => {
|
test('v-bind shorthand', () => {
|
||||||
const ast = parse('<div :a=b />')
|
const ast = parse('<div :a=b />')
|
||||||
const directive = (ast.children[0] as ElementNode).directives[0]
|
const directive = (ast.children[0] as ElementNode).props[0]
|
||||||
|
|
||||||
expect(directive).toStrictEqual({
|
expect(directive).toStrictEqual({
|
||||||
type: NodeTypes.DIRECTIVE,
|
type: NodeTypes.DIRECTIVE,
|
||||||
@ -1037,7 +1047,7 @@ describe('compiler: parse', () => {
|
|||||||
|
|
||||||
test('v-bind shorthand with modifier', () => {
|
test('v-bind shorthand with modifier', () => {
|
||||||
const ast = parse('<div :a.sync=b />')
|
const ast = parse('<div :a.sync=b />')
|
||||||
const directive = (ast.children[0] as ElementNode).directives[0]
|
const directive = (ast.children[0] as ElementNode).props[0]
|
||||||
|
|
||||||
expect(directive).toStrictEqual({
|
expect(directive).toStrictEqual({
|
||||||
type: NodeTypes.DIRECTIVE,
|
type: NodeTypes.DIRECTIVE,
|
||||||
@ -1081,7 +1091,7 @@ describe('compiler: parse', () => {
|
|||||||
|
|
||||||
test('v-on shorthand', () => {
|
test('v-on shorthand', () => {
|
||||||
const ast = parse('<div @a=b />')
|
const ast = parse('<div @a=b />')
|
||||||
const directive = (ast.children[0] as ElementNode).directives[0]
|
const directive = (ast.children[0] as ElementNode).props[0]
|
||||||
|
|
||||||
expect(directive).toStrictEqual({
|
expect(directive).toStrictEqual({
|
||||||
type: NodeTypes.DIRECTIVE,
|
type: NodeTypes.DIRECTIVE,
|
||||||
@ -1125,7 +1135,7 @@ describe('compiler: parse', () => {
|
|||||||
|
|
||||||
test('v-on shorthand with modifier', () => {
|
test('v-on shorthand with modifier', () => {
|
||||||
const ast = parse('<div @a.enter=b />')
|
const ast = parse('<div @a.enter=b />')
|
||||||
const directive = (ast.children[0] as ElementNode).directives[0]
|
const directive = (ast.children[0] as ElementNode).props[0]
|
||||||
|
|
||||||
expect(directive).toStrictEqual({
|
expect(directive).toStrictEqual({
|
||||||
type: NodeTypes.DIRECTIVE,
|
type: NodeTypes.DIRECTIVE,
|
||||||
|
@ -134,15 +134,15 @@ describe('DOM parser', () => {
|
|||||||
ns: DOMNamespaces.HTML,
|
ns: DOMNamespaces.HTML,
|
||||||
tag: 'img',
|
tag: 'img',
|
||||||
tagType: ElementTypes.ELEMENT,
|
tagType: ElementTypes.ELEMENT,
|
||||||
attrs: [],
|
props: [],
|
||||||
directives: [],
|
|
||||||
isSelfClosing: false,
|
isSelfClosing: false,
|
||||||
children: [],
|
children: [],
|
||||||
loc: {
|
loc: {
|
||||||
start: { offset: 0, line: 1, column: 1 },
|
start: { offset: 0, line: 1, column: 1 },
|
||||||
end: { offset: 5, line: 1, column: 6 },
|
end: { offset: 5, line: 1, column: 6 },
|
||||||
source: '<img>'
|
source: '<img>'
|
||||||
}
|
},
|
||||||
|
codegenNode: undefined
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user