From 863b542e3ebb0b7debb3b0188679aec7be492298 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Tue, 10 Dec 2019 13:18:21 +0300 Subject: [PATCH] Add failing test for partial attribute override Currently the default attributes are only set correctly when either none or all attributes are handed to the component --- .../unit/components/add-contribution-test.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/unit/components/add-contribution-test.js b/tests/unit/components/add-contribution-test.js index 4247ae7..21a8f9a 100644 --- a/tests/unit/components/add-contribution-test.js +++ b/tests/unit/components/add-contribution-test.js @@ -18,7 +18,24 @@ module('Unit | Component | add-contribution', function(hooks) { assert.equal(component.get(a), null, `sets the ${a} property`); }); - assert.ok(moment.isDate(component.attributes.date, 'sets the default date attribute')); + assert.ok(moment.isDate(component.attributes.date), 'sets the default date attribute'); assert.ok(moment.isDate(component.date), 'sets the default date'); }); + + test('override default attributes', function(assert) { + let component = this.owner.factoryFor('component:add-contribution').create({ + attributes: { contributorId: '1' } + }); + + assert.equal(component.contributorId, '1', `overrides the default property`); + + ['kind', 'amount', 'description', 'url', 'details'].forEach(a => { + assert.equal(component.attributes[a], null, `sets the default ${a} attribute`); + assert.equal(component.get(a), null, `sets the ${a} property`); + }); + + assert.ok(moment.isDate(component.attributes.date), 'sets the default date attribute'); + assert.ok(moment.isDate(component.date), 'sets the default date'); + }); + });