Skip to content

Commit e81f167

Browse files
authored
Merge pull request ember-bootstrap#970 from jelhan/add-template-linting-for-tests
add template linting for tests
2 parents bac36ac + 395dd99 commit e81f167

File tree

7 files changed

+211
-178
lines changed

7 files changed

+211
-178
lines changed

.eslintrc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ module.exports = {
99
}
1010
},
1111
plugins: [
12-
'ember'
12+
'ember',
13+
'hbs'
1314
],
1415
extends: [
1516
'eslint:recommended',
@@ -20,7 +21,8 @@ module.exports = {
2021
},
2122
rules: {
2223
'ember/no-jquery': 'error',
23-
'ember/no-observers': 'warn'
24+
'ember/no-observers': 'warn',
25+
'hbs/check-hbs-template-literals': 'error'
2426
},
2527
overrides: [
2628
// node files

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"ember-source-channel-url": "^2.0.1",
5555
"ember-try": "^1.4.0",
5656
"eslint-plugin-ember": "^7.7.1",
57+
"eslint-plugin-hbs": "^1.0.0",
5758
"eslint-plugin-node": "^10.0.0",
5859
"execa": "^2.0.0",
5960
"glob": "^7.1.1",

tests/integration/components/bs-form/element-test.js

Lines changed: 78 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -522,35 +522,36 @@ module('Integration | Component | bs-form/element', function(hooks) {
522522
return prev;
523523
}, {});
524524
this.setProperties(resetProps);
525-
await render(hbs`<BsForm::element @formLayout={{this.formLayout}} as |el|>
526-
<el.control
527-
name={{this.name}}
528-
required={{this.required}}
529-
readonly={{this.readonly}}
530-
placeholder={{this.placeholder}}
531-
disabled={{this.disabled}}
532-
autofocus={{this.autofocus}}
533-
size={{this.size}}
534-
tabindex={{this.tabindex}}
535-
minlength={{this.minlength}}
536-
maxlength={{this.maxlength}}
537-
min={{this.min}}
538-
max={{this.max}}
539-
pattern={{this.pattern}}
540-
accept={{this.accept}}
541-
autocomplete={{this.autocomplete}}
542-
autocapitalize={{this.autocapitalize}}
543-
autocorrect={{this.autocorrect}}
544-
autosave={{this.autosave}}
545-
inputmode={{this.inputmode}}
546-
multiple={{this.multiple}}
547-
step={{this.step}}
548-
form={{this.form}}
549-
spellcheck={{this.spellcheck}}
550-
title={{this.title}}
551-
/>
525+
await render(hbs`
526+
<BsForm::element @formLayout={{this.formLayout}} as |el|>
527+
<el.control
528+
name={{this.name}}
529+
required={{this.required}}
530+
readonly={{this.readonly}}
531+
placeholder={{this.placeholder}}
532+
disabled={{this.disabled}}
533+
autofocus={{this.autofocus}}
534+
size={{this.size}}
535+
tabindex={{this.tabindex}}
536+
minlength={{this.minlength}}
537+
maxlength={{this.maxlength}}
538+
min={{this.min}}
539+
max={{this.max}}
540+
pattern={{this.pattern}}
541+
accept={{this.accept}}
542+
autocomplete={{this.autocomplete}}
543+
autocapitalize={{this.autocapitalize}}
544+
autocorrect={{this.autocorrect}}
545+
autosave={{this.autosave}}
546+
inputmode={{this.inputmode}}
547+
multiple={{this.multiple}}
548+
step={{this.step}}
549+
form={{this.form}}
550+
spellcheck={{this.spellcheck}}
551+
title={{this.title}}
552+
/>
552553
</BsForm::element>
553-
/>`);
554+
`);
554555

555556
for (let attribute in supportedInputAttributes) {
556557
assert.equal(this.element.querySelector('input').getAttribute(attribute), undefined, `input attribute ${attribute} is undefined [${formLayout}]`);
@@ -613,29 +614,30 @@ module('Integration | Component | bs-form/element', function(hooks) {
613614
return prev;
614615
}, {});
615616
this.setProperties(resetProps);
616-
await render(hbs`<BsForm::element @formLayout={{this.formLayout}} @controlType="textarea" as |el|>
617-
<el.control
618-
name={{this.name}}
619-
rows={{this.rows}}
620-
cols={{this.cols}}
621-
required={{this.required}}
622-
readonly={{this.readonly}}
623-
placeholder={{this.placeholder}}
624-
disabled={{this.disabled}}
625-
autofocus={{this.autofocus}}
626-
tabindex={{this.tabindex}}
627-
minlength={{this.minlength}}
628-
maxlength={{this.maxlength}}
629-
autocomplete={{this.autocomplete}}
630-
autocapitalize={{this.autocapitalize}}
631-
autocorrect={{this.autocorrect}}
632-
form={{this.form}}
633-
spellcheck={{this.spellcheck}}
634-
wrap={{this.wrap}}
635-
title={{this.title}}
636-
/>
637-
</BsForm::element>
638-
/>`);
617+
await render(hbs`
618+
<BsForm::element @formLayout={{this.formLayout}} @controlType="textarea" as |el|>
619+
<el.control
620+
name={{this.name}}
621+
rows={{this.rows}}
622+
cols={{this.cols}}
623+
required={{this.required}}
624+
readonly={{this.readonly}}
625+
placeholder={{this.placeholder}}
626+
disabled={{this.disabled}}
627+
autofocus={{this.autofocus}}
628+
tabindex={{this.tabindex}}
629+
minlength={{this.minlength}}
630+
maxlength={{this.maxlength}}
631+
autocomplete={{this.autocomplete}}
632+
autocapitalize={{this.autocapitalize}}
633+
autocorrect={{this.autocorrect}}
634+
form={{this.form}}
635+
spellcheck={{this.spellcheck}}
636+
wrap={{this.wrap}}
637+
title={{this.title}}
638+
/>
639+
</BsForm::element>
640+
`);
639641

640642
for (let attribute in supportedTextareaAttributes) {
641643
assert.equal(this.element.querySelector('textarea').getAttribute(attribute), undefined, `textarea attribute ${attribute} is undefined [${formLayout}]`);
@@ -690,18 +692,19 @@ module('Integration | Component | bs-form/element', function(hooks) {
690692
return prev;
691693
}, {});
692694
this.setProperties(resetProps);
693-
await render(hbs`<BsForm::element @controlType="checkbox" @formLayout={{this.formLayout}} as |el|>
694-
<el.control
695-
name={{this.name}}
696-
required={{this.required}}
697-
disabled={{this.disabled}}
698-
autofocus={{this.autofocus}}
699-
tabindex={{this.tabindex}}
700-
form={{this.form}}
701-
title={{this.title}}
702-
/>
703-
</BsForm::element>
704-
/>`);
695+
await render(hbs`
696+
<BsForm::element @controlType="checkbox" @formLayout={{this.formLayout}} as |el|>
697+
<el.control
698+
name={{this.name}}
699+
required={{this.required}}
700+
disabled={{this.disabled}}
701+
autofocus={{this.autofocus}}
702+
tabindex={{this.tabindex}}
703+
form={{this.form}}
704+
title={{this.title}}
705+
/>
706+
</BsForm::element>
707+
`);
705708

706709
for (let attribute in supportedCheckboxAttributes) {
707710
assert.equal(this.element.querySelector('input').getAttribute(attribute), undefined, `checkbox attribute ${attribute} is undefined [${formLayout}]`);
@@ -755,18 +758,19 @@ module('Integration | Component | bs-form/element', function(hooks) {
755758
return prev;
756759
}, {});
757760
this.setProperties(resetProps);
758-
await render(hbs`<BsForm::element @controlType="radio" @formLayout={{this.formLayout}} @options={{this.options}} as |el|>
759-
<el.control
760-
name={{this.name}}
761-
required={{this.required}}
762-
disabled={{this.disabled}}
763-
autofocus={{this.autofocus}}
764-
tabindex={{this.tabindex}}
765-
form={{this.form}}
766-
title={{this.title}}
767-
/>
761+
await render(hbs`
762+
<BsForm::element @controlType="radio" @formLayout={{this.formLayout}} @options={{this.options}} as |el|>
763+
<el.control
764+
name={{this.name}}
765+
required={{this.required}}
766+
disabled={{this.disabled}}
767+
autofocus={{this.autofocus}}
768+
tabindex={{this.tabindex}}
769+
form={{this.form}}
770+
title={{this.title}}
771+
/>
768772
</BsForm::element>
769-
/>`);
773+
`);
770774

771775
for (let attribute in supportedCheckboxAttributes) {
772776
assert.equal(this.element.querySelector('input').getAttribute(attribute), undefined, `checkbox attribute ${attribute} is undefined [${formLayout}]`);

tests/integration/components/bs-popover-test.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,27 @@ module('Integration | Component | bs-popover', function(hooks) {
124124
this.set('hide', hideAction);
125125
let hiddenAction = this.spy();
126126
this.set('hidden', hiddenAction);
127-
await render(
128-
hbs`<div id="target"><BsPopover @visible={{true}} @onHide={{action hide}} @onHidden={{action hidden}} as |po|><div id="hide" {{action po.close}}>Hide</div></BsPopover></div>`
129-
);
127+
await render(hbs`
128+
<div id="target">
129+
<BsPopover @visible={{true}} @onHide={{action hide}} @onHidden={{action hidden}} as |po|>
130+
<div id="hide" {{action po.close}} role="button">Hide</div>
131+
</BsPopover>
132+
</div>
133+
`);
130134
await click('#hide');
131135
assert.ok(hideAction.calledOnce, 'hide action has been called');
132136
assert.ok(hiddenAction.calledOnce, 'hidden action was called');
133137
assert.dom('.popover').doesNotExist('popover is not visible');
134138
});
135139

136140
test('click-initiated close action does not interfere with click-to-open', async function(assert) {
137-
await render(
138-
hbs`<div id="target"><BsPopover as |po|><div id="hide" onclick={{action po.close}}>Hide</div></BsPopover></div>`
139-
);
141+
await render(hbs`
142+
<div id="target">
143+
<BsPopover as |po|>
144+
<div id="hide" onclick={{action po.close}} role="button">Hide</div>
145+
</BsPopover>
146+
</div>
147+
`);
140148
await click('#target');
141149
assert.dom('.popover').exists('popover is visible');
142150
await click('#hide');
@@ -146,9 +154,12 @@ module('Integration | Component | bs-popover', function(hooks) {
146154
});
147155

148156
test('click-initiated close action does not interfere with click-to-open when wormholed', async function(assert) {
149-
await render(
150-
hbs`<div id="ember-bootstrap-wormhole"></div><div id="target"><BsPopover as |po|><div id="hide" onclick={{action po.close}}>Hide</div></BsPopover></div>`
151-
);
157+
await render(hbs`
158+
<div id="ember-bootstrap-wormhole"></div>
159+
<div id="target">
160+
<BsPopover as |po|><div id="hide" onclick={{action po.close}} role="button">Hide</div></BsPopover>
161+
</div>
162+
`);
152163
await click('#target');
153164
assert.dom('.popover').exists('popover is visible');
154165
await click('#hide');
@@ -231,7 +242,8 @@ module('Integration | Component | bs-popover', function(hooks) {
231242

232243
test('it passes accessibility checks', async function (assert) {
233244
await render(hbs`
234-
<button>Test
245+
<button>
246+
Test
235247
<BsPopover @title="dummy title" @visible={{true}}>
236248
template block text
237249
</BsPopover>

0 commit comments

Comments
 (0)