From 7280fb90d6ec8c1a6ff29b4ab959ffbee88db83d Mon Sep 17 00:00:00 2001 From: Peter Peterson Date: Fri, 30 Sep 2016 16:31:15 -0700 Subject: [PATCH] Fix error calculating buildDuration when there is no startTime --- app/build/model.js | 2 +- tests/unit/build/model-test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/build/model.js b/app/build/model.js index eb5ef07f2..1cee46cd4 100644 --- a/app/build/model.js +++ b/app/build/model.js @@ -25,7 +25,7 @@ export default DS.Model.extend({ }), buildDuration: Ember.computed('startTime', 'endTime', { get() { - if (!this.get('endTime')) { + if (!this.get('endTime') || !this.get('startTime')) { return humanizeDuration(0); } diff --git a/tests/unit/build/model-test.js b/tests/unit/build/model-test.js index 847711c0c..b4a726208 100644 --- a/tests/unit/build/model-test.js +++ b/tests/unit/build/model-test.js @@ -32,9 +32,15 @@ test('it calculates buildDuration', function (assert) { }); Ember.run(() => { + // valid duration assert.equal(model.get('buildDuration'), '10 seconds'); + // no end time, so duration is 0 model.set('endTime', null); assert.equal(model.get('buildDuration'), '0 seconds'); + // no start time, so duration is 0 + model.set('endTime', new Date(1472244592531)); + model.set('startTime', null); + assert.equal(model.get('buildDuration'), '0 seconds'); }); });