1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00
Files
frontend/test-mocha/common/entity/timer_time_remaining_test.js
Paulus Schoutsen 912969111f Move all of hassUtil to JS (#1153)
* Move all of hassUtil to JS

* Fix tests
2018-05-09 21:33:31 -04:00

44 lines
991 B
JavaScript

import { assert } from 'chai';
import sinon from 'sinon';
import timerTimeRemaining from '../../../js/common/entity/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);
});
});
});