diff --git a/src/js/actions.ts b/src/js/actions.ts index 11705dbd..0ece97c1 100644 --- a/src/js/actions.ts +++ b/src/js/actions.ts @@ -113,7 +113,7 @@ export default class Actions { this.manipulateAndSet( lastPicked, Unit.hours, - this.dates.lastPicked.hours >= 12 ? -12 : 12 + lastPicked.hours >= 12 ? -12 : 12 ); break; case ActionTypes.togglePicker: diff --git a/test/actions.test.ts b/test/actions.test.ts index 61625bc3..157eddbc 100644 --- a/test/actions.test.ts +++ b/test/actions.test.ts @@ -410,6 +410,14 @@ test('toggleMeridiem', () => { expect(dates.picked).toEqual([shouldBe.manipulate(12, Unit.hours)]); expect(hideSpy).not.toHaveBeenCalled(); expect(isValidSpy).toHaveBeenCalled(); + + //before selecting a time + dates.clear(); + actions.do(event, ActionTypes.toggleMeridiem); + expect(setValueSpy).toHaveBeenCalled(); + expect(dates.picked).toEqual([shouldBe.manipulate(-12, Unit.hours)]); + expect(hideSpy).not.toHaveBeenCalled(); + expect(isValidSpy).toHaveBeenCalled(); }); test('togglePicker', () => {