test: fix tests after missing end tag error location fix

This commit is contained in:
Evan You 2019-12-20 10:10:08 -05:00
parent 9560ab72f8
commit 94d692b0cf
2 changed files with 53 additions and 48 deletions

View File

@ -1514,7 +1514,7 @@ describe('compiler: parse', () => {
test('invalid html', () => { test('invalid html', () => {
expect(() => { expect(() => {
parse(`<div>\n<span>\n</div>\n</span>`) parse(`<div>\n<span>\n</div>\n</span>`)
}).toThrow('End tag was not found.') }).toThrow('Element is missing end tag.')
const spy = jest.fn() const spy = jest.fn()
const ast = parse(`<div>\n<span>\n</div>\n</span>`, { const ast = parse(`<div>\n<span>\n</div>\n</span>`, {
@ -1527,8 +1527,8 @@ describe('compiler: parse', () => {
code: ErrorCodes.X_MISSING_END_TAG, code: ErrorCodes.X_MISSING_END_TAG,
loc: { loc: {
start: { start: {
offset: 13, offset: 6,
line: 3, line: 2,
column: 1 column: 1
} }
} }
@ -1833,7 +1833,7 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 11, line: 1, column: 12 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -1846,7 +1846,7 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 12, line: 1, column: 13 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
} }
@ -1861,11 +1861,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 29, line: 1, column: 30 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 29, line: 1, column: 30 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -1878,11 +1878,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 24, line: 1, column: 25 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 24, line: 1, column: 25 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
} }
@ -1897,7 +1897,7 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 21, line: 1, column: 22 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -1910,7 +1910,7 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 14, line: 1, column: 15 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -1925,7 +1925,7 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 12, line: 1, column: 13 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -1938,7 +1938,7 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 13, line: 1, column: 14 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -1951,7 +1951,7 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 15, line: 1, column: 16 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
} }
@ -1962,7 +1962,7 @@ foo
errors: [ errors: [
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 32, line: 1, column: 33 } loc: { offset: 0, line: 1, column: 1 }
}, },
{ {
type: ErrorCodes.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT, type: ErrorCodes.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT,
@ -1975,7 +1975,7 @@ foo
errors: [ errors: [
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 28, line: 1, column: 29 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
} }
@ -1990,11 +1990,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 14, line: 1, column: 15 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 14, line: 1, column: 15 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -2007,11 +2007,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 15, line: 1, column: 16 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 15, line: 1, column: 16 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -2024,11 +2024,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 17, line: 1, column: 18 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 17, line: 1, column: 18 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -2041,11 +2041,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 18, line: 1, column: 19 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 18, line: 1, column: 19 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -2062,11 +2062,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 19, line: 1, column: 20 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 19, line: 1, column: 20 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -2079,11 +2079,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 22, line: 1, column: 23 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 22, line: 1, column: 23 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -2096,11 +2096,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 22, line: 1, column: 23 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 22, line: 1, column: 23 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -2113,11 +2113,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 23, line: 1, column: 24 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 23, line: 1, column: 24 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -2130,11 +2130,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 23, line: 1, column: 24 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 23, line: 1, column: 24 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -2147,11 +2147,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 21, line: 1, column: 22 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 21, line: 1, column: 22 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -2168,11 +2168,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 24, line: 1, column: 25 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 24, line: 1, column: 25 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -2189,11 +2189,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 24, line: 1, column: 25 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 24, line: 1, column: 25 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -2210,11 +2210,11 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 23, line: 1, column: 24 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 23, line: 1, column: 24 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
} }
@ -2292,7 +2292,7 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 27, line: 1, column: 28 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
}, },
@ -2429,7 +2429,7 @@ foo
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 19, line: 1, column: 20 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
} }
@ -2651,7 +2651,7 @@ foo
errors: [ errors: [
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 15, line: 1, column: 16 } loc: { offset: 10, line: 1, column: 11 }
} }
] ]
}, },
@ -2660,11 +2660,11 @@ foo
errors: [ errors: [
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 15, line: 1, column: 16 } loc: { offset: 10, line: 1, column: 11 }
}, },
{ {
type: ErrorCodes.X_MISSING_END_TAG, type: ErrorCodes.X_MISSING_END_TAG,
loc: { offset: 15, line: 1, column: 16 } loc: { offset: 0, line: 1, column: 1 }
} }
] ]
} }

View File

@ -62,7 +62,12 @@ describe('compiler + runtime integration', () => {
} }
createApp().mount(App, container) createApp().mount(App, container)
expect( expect(
`Template compilation error: End tag was not found` `Template compilation error: Element is missing end tag`
).toHaveBeenWarned()
expect(
`
1 | <div v-if>
| ^`.trim()
).toHaveBeenWarned() ).toHaveBeenWarned()
expect(`v-if/v-else-if is missing expression`).toHaveBeenWarned() expect(`v-if/v-else-if is missing expression`).toHaveBeenWarned()
expect( expect(