Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: cleanup and fix helper focus tests #2256

Merged
merged 1 commit into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/vaadin-checkbox/test/checkbox-group.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,13 +508,12 @@ describe('slot focus', () => {
</vaadin-checkbox-group>
`);
group._observer.flush();
group.focus();
helper = group.querySelector('[slot="helper"]');
});

it('should not get focus after click', () => {
const spy = sinon.spy(group, 'focus');
helper.click();

expect(group.hasAttribute('focused')).to.be.false;
expect(spy.called).to.be.false;
});
});
7 changes: 2 additions & 5 deletions packages/vaadin-custom-field/test/helper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,16 @@ describe('helper text', () => {
beforeEach(() => {
field = fixtureSync(`
<vaadin-custom-field>
<input type="text" />

<input type="text" slot="helper" />
<input type="text" />
<input type="text" slot="helper" />
</vaadin-custom-field>
`);
helper = field.querySelector('[slot="helper"]');
field.focus();
});

it('should not focus the field on helper click', () => {
const spy = sinon.spy(field, 'focus');
helper.click();

expect(spy.called).to.be.false;
});
});
Expand Down
15 changes: 4 additions & 11 deletions packages/vaadin-text-field/test/text-area.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,18 +348,14 @@ describe('helper text', () => {
beforeEach(() => {
field = fixtureSync(`
<vaadin-text-area label="outer">
<vaadin-text-area label="inner" slot="helper">
<vaadin-text-area label="inner" slot="helper"></vaadin-text-area>
</vaadin-text-area>
<vaadin-text-area label="inner" slot="helper"></vaadin-text-area>
</vaadin-text-area>
`);
helper = field.querySelector('[slot="helper"]');
field.focus();
});

it('helper should get focus when clicked', () => {
const spy = sinon.spy(field, 'focus');

helper.click();
expect(spy.called).to.be.false;
});
Expand All @@ -369,17 +365,14 @@ describe('helper text', () => {
let field, helper;

beforeEach(() => {
field = fixtureSync(`
<vaadin-text-area label='text-field' helper-text='helper-text'>
</vaadin-text-area>
`);

field = fixtureSync('<vaadin-text-area helper-text="helper-text"></vaadin-text-area>');
helper = field.shadowRoot.querySelector('[part="helper-text"]');
});

it('should not get focus when helper text is clicked', () => {
const spy = sinon.spy(field, 'focus');
helper.click();
expect(field.hasAttribute('focused')).to.be.false;
expect(spy.called).to.be.false;
});
});
});
14 changes: 3 additions & 11 deletions packages/vaadin-text-field/test/text-field.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,15 +614,13 @@ describe('helper slot', () => {
});
});

describe('nested helper', () => {
describe('slotted helper', () => {
let field, helper;

beforeEach(() => {
field = fixtureSync(`
<vaadin-text-field label="outer">
<vaadin-text-field label="inner" slot="helper">
<vaadin-text-field label="inner" slot="helper"></vaadin-text-field>
</vaadin-text-field>
<vaadin-text-field label="inner" slot="helper"></vaadin-text-field>
</vaadin-text-field>
`);
helper = field.querySelector('[slot="helper"]');
Expand All @@ -631,7 +629,6 @@ describe('helper slot', () => {
it('helper should get focus when clicked', () => {
const spy = sinon.spy(field, 'focus');
helper.click();

expect(spy.called).to.be.false;
});
});
Expand All @@ -640,18 +637,13 @@ describe('helper slot', () => {
let field, helper;

beforeEach(() => {
field = fixtureSync(`
<vaadin-text-field label='text-field' helper-text='helper-text'>
</vaadin-text-field>
`);

field = fixtureSync('<vaadin-text-field helper-text="helper-text"></vaadin-text-field>');
helper = field.shadowRoot.querySelector('[part="helper-text"]');
});

it('should not get focus when helper text is only text', () => {
const spy = sinon.spy(field, 'focus');
helper.click();

expect(spy.called).to.be.false;
});
});
Expand Down