Skip to content

Commit

Permalink
test(tag-pair-spec): add test for correct line number/column of start…
Browse files Browse the repository at this point in the history
… tag if no end tag was provided

Do not report where the missing end tag should be closed at the latest, but the start tag.

fix htmlhint#1284
  • Loading branch information
bebehr committed Feb 18, 2024
1 parent 9d5a70f commit acb2f3d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/rules/tag-pair.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ describe(`Rules: ${ruleId}`, () => {
expect(messages[0].col).toBe(9)
})

it('No end tag should result in an error with correct line number and column of the start tag.', () => {
const code = '<div>\r\n <h1>\r\n <p>aaa</p>\r\n</div>'
const messages = HTMLHint.verify(code, ruleOptions)
expect(messages.length).toBe(1)
expect(messages[0].rule.id).toBe(ruleId)
expect(messages[0].line).toBe(2)
expect(messages[0].line).not.toBe(4)
expect(messages[0].col).toBe(3)
expect(messages[0].col).not.toBe(1)
})

it('No start tag should result in an error', () => {
const code = '</div>'
const messages = HTMLHint.verify(code, ruleOptions)
Expand Down

0 comments on commit acb2f3d

Please sign in to comment.