@@ -74,7 +74,7 @@ export default class AddReimbursementComponent extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateTotalAmountFromFiat() {
|
updateTotalAmountFromFiat() {
|
||||||
let btcAmount = parseFloat(this.total);
|
let btcAmount = 0;
|
||||||
|
|
||||||
if (this.exchangeRates.btceur > 0 && this.totalEUR > 0) {
|
if (this.exchangeRates.btceur > 0 && this.totalEUR > 0) {
|
||||||
btcAmount += (this.totalEUR / this.exchangeRates.btceur);
|
btcAmount += (this.totalEUR / this.exchangeRates.btceur);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<p class="label">Total amount (BTC):</p>
|
<p class="label">Total amount (BTC):</p>
|
||||||
<p>
|
<p>
|
||||||
<Input @type="text"
|
<Input @type="text"
|
||||||
|
@name="total-btc"
|
||||||
@placeholder="0.0015"
|
@placeholder="0.0015"
|
||||||
@value={{this.total}}
|
@value={{this.total}}
|
||||||
@required={{true}}
|
@required={{true}}
|
||||||
@@ -49,7 +50,9 @@
|
|||||||
|
|
||||||
<p class="actions">
|
<p class="actions">
|
||||||
<button {{on "click" this.showExpenseForm}}
|
<button {{on "click" this.showExpenseForm}}
|
||||||
class="green small" type="button">+ Add another item</button>
|
id="add-another-item" class="green small" type="button">
|
||||||
|
+ Add another item
|
||||||
|
</button>
|
||||||
</p>
|
</p>
|
||||||
{{else}}
|
{{else}}
|
||||||
<p>No line items yet.</p>
|
<p>No line items yet.</p>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { module, test } from 'qunit';
|
import { module, test } from 'qunit';
|
||||||
import { setupRenderingTest } from 'ember-qunit';
|
import { setupRenderingTest } from 'ember-qunit';
|
||||||
import { render } from '@ember/test-helpers';
|
import { click, fillIn, render } from '@ember/test-helpers';
|
||||||
import { hbs } from 'ember-cli-htmlbars';
|
import { hbs } from 'ember-cli-htmlbars';
|
||||||
import contributors from '../../../fixtures/contributors';
|
import contributors from '../../../fixtures/contributors';
|
||||||
|
|
||||||
@@ -22,7 +22,37 @@ module('Integration | Component | add-reimbursement', function(hooks) {
|
|||||||
assert.equal(this.element.querySelector('select#contributor option:checked').value, "3",
|
assert.equal(this.element.querySelector('select#contributor option:checked').value, "3",
|
||||||
'preselects the connected contributor account');
|
'preselects the connected contributor account');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Adding expense items', async function(assert) {
|
||||||
await render(hbs`<AddReimbursement />`);
|
await render(hbs`<AddReimbursement />`);
|
||||||
assert.ok(true);
|
|
||||||
|
assert.dom(this.element).includesText('New expense item');
|
||||||
|
|
||||||
|
await fillIn('form input[name="expense-amount"]', '49');
|
||||||
|
await fillIn('form input[name="expense-title"]', 'Domain kosmos.org (yearly fee)');
|
||||||
|
await click('form#add-expense-item input[type="submit"]');
|
||||||
|
|
||||||
|
assert.equal(this.element.querySelector('input[name="total-eur"]').value, '49',
|
||||||
|
'updates the total EUR amount');
|
||||||
|
assert.equal(this.element.querySelector('input[name="total-usd"]').value, '0',
|
||||||
|
'does not update the total USD amount');
|
||||||
|
assert.equal(this.element.querySelector('input[name="total-btc"]').value, '0.00534493',
|
||||||
|
'updates the total BTC amount');
|
||||||
|
|
||||||
|
assert.dom(this.element).doesNotIncludeText('New expense item');
|
||||||
|
|
||||||
|
await click('button#add-another-item');
|
||||||
|
|
||||||
|
await fillIn('form input[name="expense-amount"]', '29');
|
||||||
|
await fillIn('select[name="expense-currency"]', 'USD');
|
||||||
|
await fillIn('form input[name="expense-title"]', 'Domain kosmos.social (yearly fee)');
|
||||||
|
await click('form#add-expense-item input[type="submit"]');
|
||||||
|
|
||||||
|
assert.equal(this.element.querySelector('input[name="total-usd"]').value, '29',
|
||||||
|
'updates the total USD amount');
|
||||||
|
assert.equal(this.element.querySelector('input[name="total-eur"]').value, '49',
|
||||||
|
'does not update the total EUR amount');
|
||||||
|
assert.equal(this.element.querySelector('input[name="total-btc"]').value, '0.00804268',
|
||||||
|
'updates the total BTC amount');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user