Skip to content

Commit 4923156

Browse files
authored
test: cleanup and fix helper focus tests (#2256)
1 parent 2eb6148 commit 4923156

File tree

4 files changed

+11
-30
lines changed

4 files changed

+11
-30
lines changed

packages/vaadin-checkbox/test/checkbox-group.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,13 +508,12 @@ describe('slot focus', () => {
508508
</vaadin-checkbox-group>
509509
`);
510510
group._observer.flush();
511-
group.focus();
512511
helper = group.querySelector('[slot="helper"]');
513512
});
514513

515514
it('should not get focus after click', () => {
515+
const spy = sinon.spy(group, 'focus');
516516
helper.click();
517-
518-
expect(group.hasAttribute('focused')).to.be.false;
517+
expect(spy.called).to.be.false;
519518
});
520519
});

packages/vaadin-custom-field/test/helper.test.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,16 @@ describe('helper text', () => {
110110
beforeEach(() => {
111111
field = fixtureSync(`
112112
<vaadin-custom-field>
113-
<input type="text" />
114-
115-
<input type="text" slot="helper" />
113+
<input type="text" />
114+
<input type="text" slot="helper" />
116115
</vaadin-custom-field>
117116
`);
118117
helper = field.querySelector('[slot="helper"]');
119-
field.focus();
120118
});
121119

122120
it('should not focus the field on helper click', () => {
123121
const spy = sinon.spy(field, 'focus');
124122
helper.click();
125-
126123
expect(spy.called).to.be.false;
127124
});
128125
});

packages/vaadin-text-field/test/text-area.test.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,18 +348,14 @@ describe('helper text', () => {
348348
beforeEach(() => {
349349
field = fixtureSync(`
350350
<vaadin-text-area label="outer">
351-
<vaadin-text-area label="inner" slot="helper">
352-
<vaadin-text-area label="inner" slot="helper"></vaadin-text-area>
353-
</vaadin-text-area>
351+
<vaadin-text-area label="inner" slot="helper"></vaadin-text-area>
354352
</vaadin-text-area>
355353
`);
356354
helper = field.querySelector('[slot="helper"]');
357-
field.focus();
358355
});
359356

360357
it('helper should get focus when clicked', () => {
361358
const spy = sinon.spy(field, 'focus');
362-
363359
helper.click();
364360
expect(spy.called).to.be.false;
365361
});
@@ -369,17 +365,14 @@ describe('helper text', () => {
369365
let field, helper;
370366

371367
beforeEach(() => {
372-
field = fixtureSync(`
373-
<vaadin-text-area label='text-field' helper-text='helper-text'>
374-
</vaadin-text-area>
375-
`);
376-
368+
field = fixtureSync('<vaadin-text-area helper-text="helper-text"></vaadin-text-area>');
377369
helper = field.shadowRoot.querySelector('[part="helper-text"]');
378370
});
379371

380372
it('should not get focus when helper text is clicked', () => {
373+
const spy = sinon.spy(field, 'focus');
381374
helper.click();
382-
expect(field.hasAttribute('focused')).to.be.false;
375+
expect(spy.called).to.be.false;
383376
});
384377
});
385378
});

packages/vaadin-text-field/test/text-field.test.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -614,15 +614,13 @@ describe('helper slot', () => {
614614
});
615615
});
616616

617-
describe('nested helper', () => {
617+
describe('slotted helper', () => {
618618
let field, helper;
619619

620620
beforeEach(() => {
621621
field = fixtureSync(`
622622
<vaadin-text-field label="outer">
623-
<vaadin-text-field label="inner" slot="helper">
624-
<vaadin-text-field label="inner" slot="helper"></vaadin-text-field>
625-
</vaadin-text-field>
623+
<vaadin-text-field label="inner" slot="helper"></vaadin-text-field>
626624
</vaadin-text-field>
627625
`);
628626
helper = field.querySelector('[slot="helper"]');
@@ -631,7 +629,6 @@ describe('helper slot', () => {
631629
it('helper should get focus when clicked', () => {
632630
const spy = sinon.spy(field, 'focus');
633631
helper.click();
634-
635632
expect(spy.called).to.be.false;
636633
});
637634
});
@@ -640,18 +637,13 @@ describe('helper slot', () => {
640637
let field, helper;
641638

642639
beforeEach(() => {
643-
field = fixtureSync(`
644-
<vaadin-text-field label='text-field' helper-text='helper-text'>
645-
</vaadin-text-field>
646-
`);
647-
640+
field = fixtureSync('<vaadin-text-field helper-text="helper-text"></vaadin-text-field>');
648641
helper = field.shadowRoot.querySelector('[part="helper-text"]');
649642
});
650643

651644
it('should not get focus when helper text is only text', () => {
652645
const spy = sinon.spy(field, 'focus');
653646
helper.click();
654-
655647
expect(spy.called).to.be.false;
656648
});
657649
});

0 commit comments

Comments
 (0)