Skip to content

Commit 0cc0f7a

Browse files
authored
Merge pull request #38 from maxwondercorn/fix/hasValidator
Verify model exists before testing a validator exists
2 parents 9feada8 + 8c8a52f commit 0cc0f7a

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

addon/components/bs-form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default class ValidatedBsFrom extends BsForm {
88
'__ember-bootstrap_subclass' = true;
99

1010
get hasValidator() {
11-
return !!this.model.validate;
11+
return !!this.model?.validate;
1212
}
1313

1414
async validate(model) {

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,26 @@ module('Integration | Component | bs form element', function(hooks) {
150150

151151
await triggerEvent('form', 'submit');
152152
});
153+
154+
test('error is not generated when a model is not supplied when component.formElements are not used ', async function(assert) {
155+
let name;
156+
this.set('name', name);
157+
158+
this.submitAction = function() {
159+
assert.ok(true, 'submit action called.');
160+
};
161+
this.invalidAction = function() {
162+
assert.ok(true, 'Invalid action has been called.');
163+
};
164+
165+
await render(hbs`
166+
<BsForm @onSubmit={{this.submitAction}} @onInvalid={{this.invalidAction}}>
167+
<Input @type="text" @value={{this.name}} />
168+
</BsForm>
169+
`);
170+
171+
assert.expect(1);
172+
173+
await triggerEvent('form', 'submit');
174+
});
153175
});

0 commit comments

Comments
 (0)