mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-19 06:04:05 +00:00
@@ -1,4 +1,4 @@
|
|||||||
import { HttpSubscription, HttpSubscriptionOptions, OscSubscription } from 'ontime-types';
|
import { HttpSubscription, OscSubscription } from 'ontime-types';
|
||||||
import {
|
import {
|
||||||
validateOscSubscriptionObject,
|
validateOscSubscriptionObject,
|
||||||
validateOscSubscriptionCycle,
|
validateOscSubscriptionCycle,
|
||||||
@@ -79,32 +79,21 @@ describe('validateOscSubscriptionObject()', () => {
|
|||||||
|
|
||||||
describe('validateHttpSubscriptionCycle()', () => {
|
describe('validateHttpSubscriptionCycle()', () => {
|
||||||
it('should return false when given an HttpSubscription with an invalid property value', () => {
|
it('should return false when given an HttpSubscription with an invalid property value', () => {
|
||||||
const invalidBoolean = [{ url: 'http://', options: 'text=test', enabled: 'not a boolean', method: 'GET' }];
|
const invalidBoolean = [{ message: 'http://', enabled: 'not a boolean' }];
|
||||||
const invalidHttp = [{ url: 'test', options: 'text=test', enabled: true, method: 'GET' }];
|
const invalidHttp = [{ message: 'test', enabled: true }];
|
||||||
const noFtp = [{ url: 'ftp://test', options: 'text=test', enabled: true, method: 'GET' }];
|
const noFtp = [{ message: 'ftp://test', enabled: true }];
|
||||||
const noEmpty = [{ url: '', options: 'text=test', enabled: true, method: 'GET' }];
|
const noEmpty = [{ message: '', enabled: true }];
|
||||||
const invalidMethod = [{ url: '', options: 'text=test', enabled: true, method: 'GET' }];
|
|
||||||
|
|
||||||
// @ts-expect-error -- since this comes from the client, we check things that typescript would have caught
|
// @ts-expect-error -- since this comes from the client, we check things that typescript would have caught
|
||||||
expect(validateHttpSubscriptionCycle(invalidBoolean)).toBe(false);
|
expect(validateHttpSubscriptionCycle(invalidBoolean)).toBe(false);
|
||||||
// @ts-expect-error -- since this comes from the client, we check things that typescript would have caught
|
|
||||||
expect(validateHttpSubscriptionCycle(invalidMethod)).toBe(false);
|
|
||||||
// @ts-expect-error -- since this comes from the client, we check things that typescript would have caught
|
|
||||||
expect(validateHttpSubscriptionCycle(invalidHttp)).toBe(false);
|
expect(validateHttpSubscriptionCycle(invalidHttp)).toBe(false);
|
||||||
// @ts-expect-error -- since this comes from the client, we check things that typescript would have caught
|
|
||||||
expect(validateHttpSubscriptionCycle(noFtp)).toBe(false);
|
expect(validateHttpSubscriptionCycle(noFtp)).toBe(false);
|
||||||
// @ts-expect-error -- since this comes from the client, we check things that typescript would have caught
|
|
||||||
expect(validateHttpSubscriptionCycle(noEmpty)).toBe(false);
|
expect(validateHttpSubscriptionCycle(noEmpty)).toBe(false);
|
||||||
});
|
});
|
||||||
it('should return true when given an HttpSubscription matches definition', () => {
|
it('should return true when given an HttpSubscription matches definition', () => {
|
||||||
const validHttp: HttpSubscriptionOptions[] = [
|
const validHttp = [{ message: 'http://', enabled: true }];
|
||||||
{ url: 'http://', options: 'text=test', enabled: true, method: 'GET' },
|
const validHttps = [{ message: 'https://', enabled: true }];
|
||||||
{ url: 'http://', options: 'text=test', enabled: true, method: 'POST' },
|
|
||||||
];
|
|
||||||
const validHttps: HttpSubscriptionOptions[] = [
|
|
||||||
{ url: 'https://', options: 'text=test', enabled: true, method: 'GET' },
|
|
||||||
{ url: 'https://', options: 'text=test', enabled: true, method: 'POST' },
|
|
||||||
];
|
|
||||||
|
|
||||||
expect(validateHttpSubscriptionCycle(validHttp)).toBe(true);
|
expect(validateHttpSubscriptionCycle(validHttp)).toBe(true);
|
||||||
expect(validateHttpSubscriptionCycle(validHttps)).toBe(true);
|
expect(validateHttpSubscriptionCycle(validHttps)).toBe(true);
|
||||||
@@ -112,14 +101,14 @@ describe('validateHttpSubscriptionCycle()', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('validateHttpSubscriptionObject()', () => {
|
describe('validateHttpSubscriptionObject()', () => {
|
||||||
it('should returnq true when given a valid HttpSubscription', () => {
|
it('should return true when given a valid HttpSubscription', () => {
|
||||||
const validSubscription: HttpSubscription = {
|
const validSubscription: HttpSubscription = {
|
||||||
onLoad: [{ url: 'http://', options: 'text=test', enabled: true, method: 'GET' }],
|
onLoad: [{ message: 'http://', enabled: true }],
|
||||||
onStart: [{ url: 'http://', options: 'text=test', enabled: false, method: 'GET' }],
|
onStart: [{ message: 'http://', enabled: false }],
|
||||||
onPause: [{ url: 'http://', options: 'text=test', enabled: true, method: 'GET' }],
|
onPause: [{ message: 'http://', enabled: true }],
|
||||||
onStop: [{ url: 'http://', options: 'text=test', enabled: false, method: 'GET' }],
|
onStop: [{ message: 'http://', enabled: false }],
|
||||||
onUpdate: [{ url: 'http://', options: 'text=test', enabled: true, method: 'GET' }],
|
onUpdate: [{ message: 'http://', enabled: true }],
|
||||||
onFinish: [{ url: 'http://', options: 'text=test', enabled: false, method: 'GET' }],
|
onFinish: [{ message: 'http://', enabled: false }],
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = validateHttpSubscriptionObject(validSubscription);
|
const result = validateHttpSubscriptionObject(validSubscription);
|
||||||
|
|||||||
Reference in New Issue
Block a user