Files
raucao f7b174017a Add clock time-format settings and honor them in the clock
Clicking the clock opens a settings dialog; the clock renders the time with a smaller day period when the format shows one.
2026-10-27 21:49:03 +04:00

68 lines
1.7 KiB
Plaintext

import { module, test } from 'qunit';
import { setupRenderingTest } from 'dashtab/tests/helpers';
import { render, triggerEvent } from '@ember/test-helpers';
import ClockForm from 'dashtab/components/settings/clock-form';
function chooseOption(value) {
const select = document.querySelector('el-select');
const event = new Event('change', { bubbles: true });
Object.defineProperty(event, 'target', { value: { value } });
select.dispatchEvent(event);
}
module('Integration | Component | settings/clock-form', function (hooks) {
setupRenderingTest(hooks);
test('shows the current format and saves the chosen one', async function (assert) {
const calls = [];
let closed = false;
this.owner.register(
'service:clock',
{
timeFormat: '24h',
async setTimeFormat(format) {
calls.push(format);
},
},
{ instantiate: false }
);
const closeDialog = () => {
closed = true;
};
await render(<template><ClockForm @close={{closeDialog}} /></template>);
assert.dom('el-selectedcontent').hasText('24-hour');
chooseOption('12h');
await triggerEvent('form', 'submit');
assert.deepEqual(calls, ['12h']);
assert.true(closed);
});
test('saving the current format is a no-op choice', async function (assert) {
const calls = [];
this.owner.register(
'service:clock',
{
timeFormat: 'locale',
async setTimeFormat(format) {
calls.push(format);
},
},
{ instantiate: false }
);
const noop = () => {};
await render(<template><ClockForm @close={{noop}} /></template>);
await triggerEvent('form', 'submit');
assert.deepEqual(calls, ['locale']);
});
});