Skip to content

Commit 92b2c15

Browse files
committed
test(require-input-label): add failing cases for id false positive/negative
Refs: ember-template-lint/ember-template-lint#3388 - id + aria-label wrongly flagged as multipleLabels (false positive) - id alone not flagged as missing label (false negative)
1 parent 133f2a9 commit 92b2c15

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/lib/rules/template-require-input-label.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ ruleTester.run('template-require-input-label', rule, {
1919
'<template><input id="probablyHasLabel" /></template>',
2020
'<template><input aria-label={{labelText}} /></template>',
2121
'<template><input aria-labelledby="someIdValue" /></template>',
22+
// https://github.com/ember-template-lint/ember-template-lint/issues/3388
23+
// id alone does not establish a labeling relationship — a <label for> is
24+
// needed and cannot be verified statically. Only aria-label should count.
25+
'<template><input id="hello" aria-label="hello" /></template>',
2226
'<template><div></div></template>',
2327
'<template><Input id="foo" /></template>',
2428
'<template>{{input id="foo"}}</template>',
@@ -65,6 +69,13 @@ ruleTester.run('template-require-input-label', rule, {
6569
},
6670
],
6771
invalid: [
72+
// https://github.com/ember-template-lint/ember-template-lint/issues/3388
73+
// id alone does not establish a labeling relationship.
74+
{
75+
code: '<template><input id="hello" /></template>',
76+
output: null,
77+
errors: [{ message: NO_LABEL }],
78+
},
6879
{
6980
code: '<template><my-label><input /></my-label></template>',
7081
output: null,

0 commit comments

Comments
 (0)