mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-13 11:23:50 +00:00
fix: api change custom fields (#1888)
* fix: validate nested custom path * chore: add test
This commit is contained in:
committed by
GitHub
parent
80ec2d1186
commit
f128f7acd2
@@ -0,0 +1,91 @@
|
||||
import { EntryCustomFields, OntimeEvent } from 'ontime-types';
|
||||
import { isValidChangeProperty } from '../integration.utils.js';
|
||||
|
||||
describe('isValidChangeProperty()', () => {
|
||||
test('correct value and property', () => {
|
||||
const testEvent = {
|
||||
id: 'test',
|
||||
duration: 111,
|
||||
} as OntimeEvent;
|
||||
|
||||
expect(isValidChangeProperty(testEvent, 'duration', 123)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('correct property and undefined value', () => {
|
||||
const testEvent = {
|
||||
id: 'test',
|
||||
duration: 111,
|
||||
} as OntimeEvent;
|
||||
|
||||
expect(isValidChangeProperty(testEvent, 'duration', undefined)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('missing property and undefined value', () => {
|
||||
const testEvent = {
|
||||
id: 'test',
|
||||
duration: 111,
|
||||
} as OntimeEvent;
|
||||
|
||||
expect(isValidChangeProperty(testEvent, 'missing', 123)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('non existing custom value', () => {
|
||||
const testEvent = {
|
||||
id: 'test',
|
||||
duration: 111,
|
||||
custom: {
|
||||
field: 'test',
|
||||
} as EntryCustomFields,
|
||||
} as OntimeEvent;
|
||||
|
||||
expect(isValidChangeProperty(testEvent, 'custom:test', 123)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('existing custom value', () => {
|
||||
const testEvent = {
|
||||
id: 'test',
|
||||
duration: 111,
|
||||
custom: {
|
||||
test: 'test',
|
||||
} as EntryCustomFields,
|
||||
} as OntimeEvent;
|
||||
|
||||
expect(isValidChangeProperty(testEvent, 'custom:test', 123)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('empty custom definition', () => {
|
||||
const testEvent = {
|
||||
id: 'test',
|
||||
duration: 111,
|
||||
custom: {
|
||||
test: 'test',
|
||||
} as EntryCustomFields,
|
||||
} as OntimeEvent;
|
||||
|
||||
expect(isValidChangeProperty(testEvent, 'custom:', 123)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('build-in in custom', () => {
|
||||
const testEvent = {
|
||||
id: 'test',
|
||||
duration: 111,
|
||||
custom: {
|
||||
test: 'test',
|
||||
} as EntryCustomFields,
|
||||
} as OntimeEvent;
|
||||
|
||||
expect(isValidChangeProperty(testEvent, 'custom:toString', 123)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('build-in in top object', () => {
|
||||
const testEvent = {
|
||||
id: 'test',
|
||||
duration: 111,
|
||||
custom: {
|
||||
test: 'test',
|
||||
} as EntryCustomFields,
|
||||
} as OntimeEvent;
|
||||
|
||||
expect(isValidChangeProperty(testEvent, 'toString', 123)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user