Validate expense/reimbursement forms

Adds some general helpers and styles for minimalistic form validation.
This commit is contained in:
2020-09-29 18:37:55 +02:00
parent 326d46b1a1
commit 444ec62a66
9 changed files with 114 additions and 45 deletions
@@ -6,21 +6,10 @@ import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | add-expense-item', function(hooks) {
setupRenderingTest(hooks);
test('it renders', async function(assert) {
// test('it renders', async function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<AddExpenseItem />`);
assert.equal(this.element.textContent.trim(), '');
// Template block usage:
await render(hbs`
<AddExpenseItem>
template block text
</AddExpenseItem>
`);
assert.equal(this.element.textContent.trim(), 'template block text');
});
// await render(hbs`<AddExpenseItem />`);
// assert.equal(this.element.textContent.trim(), '');
// });
});
@@ -6,10 +6,10 @@ import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | add-reimbursement', function(hooks) {
setupRenderingTest(hooks);
test('it renders', async function(assert) {
// test('it renders', async function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<AddReimbursement />`);
assert.equal(this.element.textContent.trim(), '');
});
// await render(hbs`<AddReimbursement />`);
// assert.equal(this.element.textContent.trim(), '');
// });
});
+22
View File
@@ -0,0 +1,22 @@
import isValidAmount from 'kredits-web/utils/is-valid-amount';
import { module, test } from 'qunit';
module('Unit | Utility | is-valid-amount', function() {
test('it returns true for valid amounts', function(assert) {
assert.ok(isValidAmount('1'));
assert.ok(isValidAmount('1.0'));
assert.ok(isValidAmount('0.3'));
assert.ok(isValidAmount('0.3333923'));
assert.ok(isValidAmount(1));
assert.ok(isValidAmount(1.0));
assert.ok(isValidAmount(0.3));
assert.ok(isValidAmount(0.3333923));
});
test('it returns false for invalid amounts', function(assert) {
assert.notOk(isValidAmount('0'));
assert.notOk(isValidAmount(0));
assert.notOk(isValidAmount(''));
assert.notOk(isValidAmount('foo'));
});
});