mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-24 04:39:01 +00:00
* Add timer card and badge * Disable interval on disconnect * Tests! * One more test case * Remove padStart * Remove state from timer state card
44 lines
989 B
JavaScript
44 lines
989 B
JavaScript
import { assert } from 'chai';
|
|
import sinon from 'sinon';
|
|
|
|
import timerTimeRemaining from '../../../js/common/util/timer_time_remaining.js';
|
|
|
|
describe('timerTimeRemaining', () => {
|
|
it('works with idle timers', () => {
|
|
assert.strictEqual(timerTimeRemaining({
|
|
state: 'idle',
|
|
attributes: {
|
|
remaining: '0:01:05'
|
|
}
|
|
}), 65);
|
|
});
|
|
|
|
it('works with paused timers', () => {
|
|
assert.strictEqual(timerTimeRemaining({
|
|
state: 'paused',
|
|
attributes: {
|
|
remaining: '0:01:05'
|
|
}
|
|
}), 65);
|
|
});
|
|
|
|
describe('active timers', () => {
|
|
let clock;
|
|
beforeEach(() => {
|
|
clock = sinon.useFakeTimers(new Date('2018-01-17T16:15:30Z'));
|
|
});
|
|
afterEach(() => {
|
|
clock.restore();
|
|
});
|
|
it('works', () => {
|
|
assert.strictEqual(timerTimeRemaining({
|
|
state: 'active',
|
|
attributes: {
|
|
remaining: '0:01:05'
|
|
},
|
|
last_changed: '2018-01-17T16:15:12Z',
|
|
}), 47);
|
|
});
|
|
});
|
|
});
|