Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

[beta] Explicitly set seconds to 0 from selector (#4559) #4571

Merged
merged 1 commit into from
Feb 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions js/src/ui/GasPriceEditor/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ export default class GasPriceEditor {

switch (conditionType) {
case CONDITIONS.BLOCK:
this.condition = Object.assign({}, this.condition, { block: this.blockNumber || 1 });
this.setConditionBlockNumber(this.blockNumber || 1);
break;

case CONDITIONS.TIME:
this.condition = Object.assign({}, this.condition, { time: new Date() });
this.setConditionDateTime(new Date());
break;

case CONDITIONS.NONE:
Expand All @@ -103,7 +103,12 @@ export default class GasPriceEditor {
});
}

@action setConditionDateTime = (time) => {
@action setConditionDateTime = (_time) => {
const time = new Date(_time);

time.setMilliseconds(0); // ignored by/not passed to Parity
time.setSeconds(0); // current time selector doesn't allow seconds

this.condition = Object.assign({}, this.condition, { time });
}

Expand Down
14 changes: 11 additions & 3 deletions js/src/ui/GasPriceEditor/store.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,17 @@ describe('ui/GasPriceEditor/Store', () => {
});

describe('setConditionDateTime', () => {
it('sets the datatime', () => {
store.setConditionDateTime('testingDateTime');
expect(store.condition.time).to.equal('testingDateTime');
const BASEDATE = '1973-06-11 07:52';
const ZEROTIME = new Date(BASEDATE).getTime();

it('sets the datetime', () => {
store.setConditionDateTime(new Date(`${BASEDATE}:00.000`));
expect(store.condition.time.getTime()).to.equal(ZEROTIME);
});

it('zeros both seconds and miliseconds', () => {
store.setConditionDateTime(new Date(`${BASEDATE}:12.345`));
expect(store.condition.time.getTime()).to.equal(ZEROTIME);
});
});

Expand Down