Skip to content

Commit

Permalink
updates test coverage for ValidationError component.
Browse files Browse the repository at this point in the history
this ditches the "it responds to changes" testcase, since this would now
require rigging up a test fixture that's responsive, like a dummy
component.
way too much effort - we're already testing validation error state
changes in integration tests that utilize the ValidationError component.
  • Loading branch information
stopfstedt committed Oct 30, 2024
1 parent 5ef2644 commit 78bc07a
Showing 1 changed file with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,43 @@ module('Integration | Component | validation-error', function (hooks) {
setupRenderingTest(hooks);

test('it renders with no errors', async function (assert) {
await render(hbs`<ValidationError @errors={{(array)}} />`);
assert.expect(2);

const propertyName = 'foo';

this.set('validatable', {
async getErrorsFor(prop) {
assert.strictEqual(prop, propertyName);
return [];
},
});
this.set('propertyName', propertyName);

await render(
hbs`<ValidationError @validatable={{this.validatable}} @property={{this.propertyName}} />`,
);

assert.dom(this.element).hasText('');
});

test('it renders with errors', async function (assert) {
await render(hbs`<ValidationError @errors={{array 'test 1' 'test 2'}} />`);
assert.expect(2);

assert.dom(this.element).hasText('test 1 test 2');
});

test('it responds to changes', async function (assert) {
this.set('errors', ['one']);
await render(hbs`<ValidationError @errors={{this.errors}} />`);
const propertyName = 'foo';
const errors = ['test 1', 'test 2'];

assert.dom(this.element).hasText('one');
this.set('validatable', {
async getErrorsFor(prop) {
assert.strictEqual(prop, propertyName);
return errors;
},
});
this.set('propertyName', propertyName);

this.set('errors', ['two']);
assert.dom(this.element).hasText('two');
await render(
hbs`<ValidationError @validatable={{this.validatable}} @property={{this.propertyName}} />`,
);

this.set('errors', []);
assert.dom(this.element).hasText('');
assert.dom(this.element).hasText(errors.join(' '));
});
});

0 comments on commit 78bc07a

Please sign in to comment.