test(store): cover recordTrain validation and getSummary on unknown attr
This commit is contained in:
@@ -99,3 +99,20 @@ test('Store: getSummary returns computed summary for attribute', () => {
|
||||
assert.equal(sum.trainsToday, 2);
|
||||
assert.equal(sum.perDay, Math.floor((2 / 7) * 247));
|
||||
});
|
||||
|
||||
test('Store: recordTrain rejects non-positive and non-number deltas', () => {
|
||||
const s = freshStore();
|
||||
assert.equal(s.recordTrain('strength', 0, NOW), false);
|
||||
assert.equal(s.recordTrain('strength', -5, NOW), false);
|
||||
assert.equal(s.recordTrain('strength', '10', NOW), false);
|
||||
assert.equal(s.recordTrain('strength', NaN, NOW), false);
|
||||
assert.equal(s.history.strength, undefined);
|
||||
});
|
||||
|
||||
test('Store: getSummary on unknown attribute returns zeros', () => {
|
||||
const s = freshStore();
|
||||
const sum = s.getSummary('nonexistent', NOW);
|
||||
assert.equal(sum.trainsToday, 0);
|
||||
assert.equal(sum.sevenDayAvgPerDay, 0);
|
||||
assert.equal(sum.perDay, 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user