[Timer] Updated Timer UI and fixed tests

Added peeking stop button to view, added legacy and first run support, added new and fixed old tests
This commit is contained in:
DJ
2017-01-25 18:21:52 -06:00
parent ecf1bac5c7
commit 60a8ee657a
12 changed files with 223 additions and 94 deletions

View File

@@ -62,27 +62,34 @@ define(
action = new PauseTimerAction(mockNow, testContext);
});
it("updates the model with a timestamp", function () {
it("updates the model with a timerState", function () {
testModel.timerState = 'started';
action.perform();
expect(testModel.timerState).toEqual('paused');
});
it("updates the model with a pausedTime", function () {
testModel.pausedTime = undefined;
mockNow.andReturn(12000);
action.perform();
expect(testModel.timestamp).toEqual(12000);
expect(testModel.pausedTime).toEqual(12000);
});
it("applies only to timers in a playing state", function () {
//in a stopped state
testStates(testModel, 'timer', undefined, undefined, false);
testState('timer', 'stopped', undefined, false);
//in a paused state
testStates(testModel, 'timer', 'pause', undefined, false);
testState('timer', 'paused', 12000, false);
//in a playing state
testStates(testModel, 'timer', 'play', undefined, true);
testState('timer', 'started', 12000, true);
//not a timer
testStates(testModel, 'clock', 'pause', undefined, false);
testState('clock', 'started', 12000, false);
});
function testStates(testModel, type, timerState, timestamp, expected) {
function testState(type, timerState, timestamp, expected) {
testModel.type = type;
testModel.timerState = timerState;
testModel.timestamp = timestamp;
@@ -92,11 +99,6 @@ define(
} else {
expect(PauseTimerAction.appliesTo(testContext)).toBeFalsy()
}
//first test without time, this test with time
if (timestamp === undefined) {
testStates(testModel, type, timerState, 12000, expected);
}
}
});
}