Skip to content

Commit

Permalink
added test as sub-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
mukherjeesudebi committed May 4, 2023
1 parent 4c14847 commit a06daa6
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 162 deletions.
48 changes: 21 additions & 27 deletions test/email-field-events.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,32 @@
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
});
});

describe('has-input-value-changed event with clear button', () => {
beforeEach(async() => {
hasInputValueChangedSpy = sinon.spy();
valueChangedSpy = sinon.spy();
emailField = fixture('email-field');
emailField.addEventListener('has-input-value-changed', hasInputValueChangedSpy);
emailField.addEventListener('value-changed', valueChangedSpy);
input = emailField.inputElement;
emailField.clearButtonVisible = true;
});

describe('with user input', () => {
describe('with clear button', () => {
beforeEach(async() => {
input.value = 'foo';
input.dispatchEvent(new CustomEvent('input'));
hasInputValueChangedSpy.reset();
valueChangedSpy.reset();
emailField.clearButtonVisible = true;
});

it('should fire the event on clear button click', async() => {
emailField.$.clearButton.click();
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
describe('with user input', () => {
beforeEach(async() => {
input.value = 'foo';
input.dispatchEvent(new CustomEvent('input'));
hasInputValueChangedSpy.reset();
valueChangedSpy.reset();
});

it('should fire the event on Esc', async() => {
input.focus();
MockInteractions.keyDownOn(input, 27, null, 'Escape');
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
it('should fire the event on clear button click', async() => {
emailField.$.clearButton.click();
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});

it('should fire the event on Esc', async() => {
input.focus();
MockInteractions.keyDownOn(input, 27, null, 'Escape');
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
});
});
});
Expand Down
48 changes: 21 additions & 27 deletions test/integer-field-events.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,32 @@
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
});
});

describe('has-input-value-changed event with clear button', () => {
beforeEach(async() => {
hasInputValueChangedSpy = sinon.spy();
valueChangedSpy = sinon.spy();
integerField = fixture('integer-field');
integerField.addEventListener('has-input-value-changed', hasInputValueChangedSpy);
integerField.addEventListener('value-changed', valueChangedSpy);
input = integerField.inputElement;
integerField.clearButtonVisible = true;
});

describe('with user input', () => {
describe('with clear button', () => {
beforeEach(async() => {
input.value = '5';
input.dispatchEvent(new CustomEvent('input'));
hasInputValueChangedSpy.reset();
valueChangedSpy.reset();
integerField.clearButtonVisible = true;
});

it('should fire the event on clear button click', async() => {
integerField.$.clearButton.click();
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
describe('with user input', () => {
beforeEach(async() => {
input.value = '5';
input.dispatchEvent(new CustomEvent('input'));
hasInputValueChangedSpy.reset();
valueChangedSpy.reset();
});

it('should fire the event on Esc', async() => {
input.focus();
MockInteractions.keyDownOn(input, 27, null, 'Escape');
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
it('should fire the event on clear button click', async() => {
integerField.$.clearButton.click();
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});

it('should fire the event on Esc', async() => {
input.focus();
MockInteractions.keyDownOn(input, 27, null, 'Escape');
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
});
});
});
Expand Down
48 changes: 21 additions & 27 deletions test/number-field-events.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,32 @@
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
});
});

describe('has-input-value-changed event with clear button', () => {
beforeEach(async() => {
hasInputValueChangedSpy = sinon.spy();
valueChangedSpy = sinon.spy();
numberField = fixture('number-field');
numberField.addEventListener('has-input-value-changed', hasInputValueChangedSpy);
numberField.addEventListener('value-changed', valueChangedSpy);
input = numberField.inputElement;
numberField.clearButtonVisible = true;
});

describe('with user input', () => {
describe('with clear button', () => {
beforeEach(async() => {
input.value = '5';
input.dispatchEvent(new CustomEvent('input'));
hasInputValueChangedSpy.reset();
valueChangedSpy.reset();
numberField.clearButtonVisible = true;
});

it('should fire the event on clear button click', async() => {
numberField.$.clearButton.click();
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
describe('with user input', () => {
beforeEach(async() => {
input.value = '5';
input.dispatchEvent(new CustomEvent('input'));
hasInputValueChangedSpy.reset();
valueChangedSpy.reset();
});

it('should fire the event on Esc', async() => {
input.focus();
MockInteractions.keyDownOn(input, 27, null, 'Escape');
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
it('should fire the event on clear button click', async() => {
numberField.$.clearButton.click();
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});

it('should fire the event on Esc', async() => {
input.focus();
MockInteractions.keyDownOn(input, 27, null, 'Escape');
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
});
});
});
Expand Down
48 changes: 21 additions & 27 deletions test/password-field-events.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,32 @@
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
});
});

describe('has-input-value-changed event with clear button', () => {
beforeEach(async() => {
hasInputValueChangedSpy = sinon.spy();
valueChangedSpy = sinon.spy();
passwordField = fixture('password-field');
passwordField.addEventListener('has-input-value-changed', hasInputValueChangedSpy);
passwordField.addEventListener('value-changed', valueChangedSpy);
input = passwordField.inputElement;
passwordField.clearButtonVisible = true;
});

describe('with user input', () => {
describe('with clear button', () => {
beforeEach(async() => {
input.value = 'foo';
input.dispatchEvent(new CustomEvent('input'));
hasInputValueChangedSpy.reset();
valueChangedSpy.reset();
passwordField.clearButtonVisible = true;
});

it('should fire the event on clear button click', async() => {
passwordField.$.clearButton.click();
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
describe('with user input', () => {
beforeEach(async() => {
input.value = 'foo';
input.dispatchEvent(new CustomEvent('input'));
hasInputValueChangedSpy.reset();
valueChangedSpy.reset();
});

it('should fire the event on Esc', async() => {
input.focus();
MockInteractions.keyDownOn(input, 27, null, 'Escape');
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
it('should fire the event on clear button click', async() => {
passwordField.$.clearButton.click();
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});

it('should fire the event on Esc', async() => {
input.focus();
MockInteractions.keyDownOn(input, 27, null, 'Escape');
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
});
});
});
Expand Down
48 changes: 21 additions & 27 deletions test/text-area-events.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,32 @@
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
});
});

describe('has-input-value-changed event with clear button', () => {
beforeEach(async() => {
hasInputValueChangedSpy = sinon.spy();
valueChangedSpy = sinon.spy();
textArea = fixture('text-area');
textArea.addEventListener('has-input-value-changed', hasInputValueChangedSpy);
textArea.addEventListener('value-changed', valueChangedSpy);
input = textArea.inputElement;
textArea.clearButtonVisible = true;
});

describe('with user input', () => {
describe('with clear button', () => {
beforeEach(async() => {
input.value = 'foo';
input.dispatchEvent(new CustomEvent('input'));
hasInputValueChangedSpy.reset();
valueChangedSpy.reset();
textArea.clearButtonVisible = true;
});

it('should fire the event on clear button click', async() => {
textArea.$.clearButton.click();
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
describe('with user input', () => {
beforeEach(async() => {
input.value = 'foo';
input.dispatchEvent(new CustomEvent('input'));
hasInputValueChangedSpy.reset();
valueChangedSpy.reset();
});

it('should fire the event on Esc', async() => {
input.focus();
MockInteractions.keyDownOn(input, 27, null, 'Escape');
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
it('should fire the event on clear button click', async() => {
textArea.$.clearButton.click();
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});

it('should fire the event on Esc', async() => {
input.focus();
MockInteractions.keyDownOn(input, 27, null, 'Escape');
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
});
});
});
Expand Down
48 changes: 21 additions & 27 deletions test/text-field-events.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,32 @@
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
});
});

describe('has-input-value-changed event with clear button', () => {
beforeEach(async() => {
hasInputValueChangedSpy = sinon.spy();
valueChangedSpy = sinon.spy();
textField = fixture('text-field');
textField.addEventListener('has-input-value-changed', hasInputValueChangedSpy);
textField.addEventListener('value-changed', valueChangedSpy);
input = textField.inputElement;
textField.clearButtonVisible = true;
});

describe('with user input', () => {
describe('with clear button', () => {
beforeEach(async() => {
input.value = 'foo';
input.dispatchEvent(new CustomEvent('input'));
hasInputValueChangedSpy.reset();
valueChangedSpy.reset();
textField.clearButtonVisible = true;
});

it('should fire the event on clear button click', async() => {
textField.$.clearButton.click();
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
describe('with user input', () => {
beforeEach(async() => {
input.value = 'foo';
input.dispatchEvent(new CustomEvent('input'));
hasInputValueChangedSpy.reset();
valueChangedSpy.reset();
});

it('should fire the event on Esc', async() => {
input.focus();
MockInteractions.keyDownOn(input, 27, null, 'Escape');
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
it('should fire the event on clear button click', async() => {
textField.$.clearButton.click();
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});

it('should fire the event on Esc', async() => {
input.focus();
MockInteractions.keyDownOn(input, 27, null, 'Escape');
expect(hasInputValueChangedSpy.calledOnce).to.be.true;
expect(hasInputValueChangedSpy.calledBefore(valueChangedSpy)).to.be.true;
});
});
});
});
Expand Down

0 comments on commit a06daa6

Please sign in to comment.