mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-07 18:09:47 +00:00
* Fix type issues * Extract backup-upload * Add onboarding upload section * Extract and use ha-backup-details * Implement backup details and restore * remove unused hassio onboarding calls * Require hass in dialog-hassio-backup * Add restore view * Add formatDateTime without locale and config * Add restore status * Fix prettier * Fix styles of backup details * Remove unused localize * Fix onboarding restore translations * Hide data-picker on core only instance * Split uploadBackup into 2 separate funcs * Add formatDateTimeWithBrowserDefaults * Fix selected data for core only * Show error reasons on status page * Use new backup info agents * Add mem function for formatDateTimeWithBrowserDefaults * Fix overflow on mobile * Handle errors when in hassio mode * Fix cancel restore texts * Fix hassio localize type issue * Remove unused onboarding localize in hassio backup restore * improve format_date_time * Fix tests * Fix and simplify backup upload issues * Use foreach instead of reduce * Fix attributes, unused styles and properties * Simplify supervisor warning * Fix language type issues * Fix ha-backup-data-picker * Improve backup-details-restore * Fix onboarding-restore issues * Improve loadBackupInfo * Revert uploadBackup changes * Improve cancel restore * Use destructive * Update src/panels/config/backup/dialogs/dialog-upload-backup.ts Co-authored-by: Bram Kragten <mail@bramkragten.nl> * Show backup type not at onboarding * Only show backup type in correct translationPanel * Fix quotes --------- Co-authored-by: Bram Kragten <mail@bramkragten.nl>
142 lines
3.6 KiB
TypeScript
142 lines
3.6 KiB
TypeScript
import { assert, describe, it } from "vitest";
|
|
|
|
import {
|
|
formatDateTime,
|
|
formatDateTimeWithSeconds,
|
|
formatDateTimeNumeric,
|
|
formatDateTimeWithBrowserDefaults,
|
|
} from "../../../src/common/datetime/format_date_time";
|
|
import {
|
|
NumberFormat,
|
|
TimeFormat,
|
|
FirstWeekday,
|
|
DateFormat,
|
|
TimeZone,
|
|
} from "../../../src/data/translation";
|
|
import { demoConfig } from "../../../src/fake_data/demo_config";
|
|
|
|
describe("formatDateTime", () => {
|
|
const dateObj = new Date(2017, 10, 18, 23, 12, 13, 400);
|
|
|
|
it("Formats English date times", () => {
|
|
assert.strictEqual(
|
|
formatDateTime(
|
|
dateObj,
|
|
{
|
|
language: "en",
|
|
number_format: NumberFormat.language,
|
|
time_format: TimeFormat.am_pm,
|
|
date_format: DateFormat.language,
|
|
time_zone: TimeZone.local,
|
|
first_weekday: FirstWeekday.language,
|
|
},
|
|
demoConfig
|
|
),
|
|
"November 18, 2017 at 11:12 PM"
|
|
);
|
|
assert.strictEqual(
|
|
formatDateTime(
|
|
dateObj,
|
|
{
|
|
language: "en",
|
|
number_format: NumberFormat.language,
|
|
time_format: TimeFormat.twenty_four,
|
|
date_format: DateFormat.language,
|
|
time_zone: TimeZone.local,
|
|
first_weekday: FirstWeekday.language,
|
|
},
|
|
demoConfig
|
|
),
|
|
"November 18, 2017 at 23:12"
|
|
);
|
|
});
|
|
|
|
it("Formats date times without optional params", () => {
|
|
assert.strictEqual(
|
|
formatDateTimeWithBrowserDefaults(dateObj),
|
|
new Intl.DateTimeFormat(undefined, {
|
|
year: "numeric",
|
|
month: "long",
|
|
day: "numeric",
|
|
hour: "2-digit",
|
|
minute: "2-digit",
|
|
}).format(dateObj)
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("formatDateTimeWithSeconds", () => {
|
|
const dateObj = new Date(2017, 10, 18, 23, 12, 13, 400);
|
|
|
|
it("Formats English date times with seconds", () => {
|
|
assert.strictEqual(
|
|
formatDateTimeWithSeconds(
|
|
dateObj,
|
|
{
|
|
language: "en",
|
|
number_format: NumberFormat.language,
|
|
time_format: TimeFormat.am_pm,
|
|
date_format: DateFormat.language,
|
|
time_zone: TimeZone.local,
|
|
first_weekday: FirstWeekday.language,
|
|
},
|
|
demoConfig
|
|
),
|
|
"November 18, 2017 at 11:12:13 PM"
|
|
);
|
|
assert.strictEqual(
|
|
formatDateTimeWithSeconds(
|
|
dateObj,
|
|
{
|
|
language: "en",
|
|
number_format: NumberFormat.language,
|
|
time_format: TimeFormat.twenty_four,
|
|
date_format: DateFormat.language,
|
|
time_zone: TimeZone.local,
|
|
|
|
first_weekday: FirstWeekday.language,
|
|
},
|
|
demoConfig
|
|
),
|
|
"November 18, 2017 at 23:12:13"
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("formatDateTimeNumeric", () => {
|
|
const dateObj = new Date(2017, 10, 18, 23, 12, 13, 400);
|
|
|
|
it("Formats English numeric date times", () => {
|
|
assert.strictEqual(
|
|
formatDateTimeNumeric(
|
|
dateObj,
|
|
{
|
|
language: "en",
|
|
number_format: NumberFormat.language,
|
|
time_format: TimeFormat.am_pm,
|
|
date_format: DateFormat.language,
|
|
time_zone: TimeZone.local,
|
|
first_weekday: FirstWeekday.language,
|
|
},
|
|
demoConfig
|
|
),
|
|
"11/18/2017, 11:12 PM"
|
|
);
|
|
assert.strictEqual(
|
|
formatDateTimeNumeric(
|
|
dateObj,
|
|
{
|
|
language: "en",
|
|
number_format: NumberFormat.language,
|
|
time_format: TimeFormat.twenty_four,
|
|
date_format: DateFormat.language,
|
|
time_zone: TimeZone.local,
|
|
first_weekday: FirstWeekday.language,
|
|
},
|
|
demoConfig
|
|
),
|
|
"11/18/2017, 23:12"
|
|
);
|
|
});
|
|
});
|