Refactor: require trigger in all events objects (#1636)

* reqire trigger in all events

* use structuredClone when cloning an event
This commit is contained in:
Alex Christoffer Rasmussen
2025-06-12 09:54:57 +02:00
committed by GitHub
parent 02c30c9681
commit 2a5b053d97
7 changed files with 31 additions and 5 deletions
@@ -28,6 +28,7 @@ describe('cloneEvent()', () => {
delay: 0,
dayOffset: 0,
gap: 0,
triggers: [],
custom: {
lighting: '3',
} as EntryCustomFields,
@@ -36,6 +37,7 @@ describe('cloneEvent()', () => {
const cloned = cloneEvent(original);
expect(cloned).not.toBe(original);
expect(cloned.custom).not.toBe(original.custom);
expect(cloned.triggers).not.toBe(original.triggers);
expect(cloned).toMatchObject({
type: SupportedEntry.Event,
@@ -59,6 +61,8 @@ describe('cloneEvent()', () => {
gap: 0,
timeWarning: original.timeWarning,
timeDanger: original.timeDanger,
triggers: original.triggers,
custom: original.custom,
});
});
});
+2 -1
View File
@@ -30,6 +30,7 @@ export const cloneEvent = (event: OntimeEvent): ClonedEvent => {
gap: 0,
timeWarning: event.timeWarning,
timeDanger: event.timeDanger,
custom: { ...event.custom },
triggers: structuredClone(event.triggers),
custom: structuredClone(event.custom),
};
};