[Timer] Updated Timer UI to indicate playing or paused state

Removed PauseCheck & TimeOfPause from properties, Removed duplicate functionality Resume class , replaced peeking restart at 0 button with persistent play/pause button
This commit is contained in:
DJ
2017-01-18 07:08:54 -06:00
parent d04bdd2685
commit ecf1bac5c7
15 changed files with 201 additions and 330 deletions

View File

@@ -33,10 +33,10 @@ define(
function asPromise(value) {
return (value || {}).then ? value : {
then: function (callback) {
return asPromise(callback(value));
}
};
then: function (callback) {
return asPromise(callback(value));
}
};
}
beforeEach(function () {
@@ -57,7 +57,7 @@ define(
});
testModel = {};
testContext = { domainObject: mockDomainObject };
testContext = {domainObject: mockDomainObject};
action = new StartTimerAction(mockNow, testContext);
});
@@ -68,19 +68,36 @@ define(
expect(testModel.timestamp).toEqual(12000);
});
it("applies only to timers without a target time", function () {
testModel.type = 'timer';
testModel.timestamp = 12000;
expect(StartTimerAction.appliesTo(testContext)).toBeFalsy();
it("applies only to timers not in a playing state", function () {
//in a stopped state
testStates(testModel, 'timer', undefined, undefined, true);
testModel.type = 'timer';
testModel.timestamp = undefined;
expect(StartTimerAction.appliesTo(testContext)).toBeTruthy();
//in a paused state
testStates(testModel, 'timer', 'pause', undefined, true);
testModel.type = 'clock';
testModel.timestamp = 12000;
expect(StartTimerAction.appliesTo(testContext)).toBeFalsy();
//in a playing state
testStates(testModel, 'timer', 'play', undefined, false);
//not a timer
testStates(testModel, 'clock', 'pause', undefined, false);
});
function testStates(testModel, type, timerState, timestamp, expected) {
testModel.type = type;
testModel.timerState = timerState;
testModel.timestamp = timestamp;
if (expected) {
expect(StartTimerAction.appliesTo(testContext)).toBeTruthy()
} else {
expect(StartTimerAction.appliesTo(testContext)).toBeFalsy()
}
//first test without time, this test with time
if (timestamp === undefined) {
testStates(testModel, type, timerState, 12000, expected);
}
}
});
}
);