mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 12:23:51 +00:00
fix and test only space osc payload (#1052)
This commit is contained in:
committed by
GitHub
parent
48ebd31c54
commit
6f7846bbf7
@@ -116,6 +116,18 @@ describe('parseNestedTemplate() -> stringToOSCArgs()', () => {
|
|||||||
test: '"string with space and {{not.so.easy}}"',
|
test: '"string with space and {{not.so.easy}}"',
|
||||||
expect: [{ type: 'string', value: 'string with space and data with space' }],
|
expect: [{ type: 'string', value: 'string with space and data with space' }],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: '',
|
||||||
|
expect: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: ' ',
|
||||||
|
expect: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: '""',
|
||||||
|
expect: [{ type: 'string', value: '' }],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
test: '"string with space and {{not.so.empty}}"',
|
test: '"string with space and {{not.so.empty}}"',
|
||||||
expect: [{ type: 'string', value: 'string with space and ' }],
|
expect: [{ type: 'string', value: 'string with space and ' }],
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ describe('test stringToOSCArgs()', () => {
|
|||||||
expect(stringToOSCArgs(test)).toStrictEqual(expected);
|
expect(stringToOSCArgs(test)).toStrictEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('1 space is nothing', () => {
|
||||||
|
const test = ' ';
|
||||||
|
const expected = [];
|
||||||
|
expect(stringToOSCArgs(test)).toStrictEqual(expected);
|
||||||
|
});
|
||||||
|
|
||||||
it('keep other types in strings', () => {
|
it('keep other types in strings', () => {
|
||||||
const test = 'test "1111" "0.1111" "TRUE" "FALSE"';
|
const test = 'test "1111" "0.1111" "TRUE" "FALSE"';
|
||||||
const expected = [
|
const expected = [
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ export function stringToOSCArgs(argsString: string | undefined): Argument[] {
|
|||||||
}
|
}
|
||||||
const matches = splitWhitespace(argsString);
|
const matches = splitWhitespace(argsString);
|
||||||
|
|
||||||
|
if (!matches) {
|
||||||
|
return new Array<Argument>();
|
||||||
|
}
|
||||||
|
|
||||||
const parsedArguments: Argument[] = matches.map((argString: string) => {
|
const parsedArguments: Argument[] = matches.map((argString: string) => {
|
||||||
const argAsNum = Number(argString);
|
const argAsNum = Number(argString);
|
||||||
// NOTE: number like: 1 2.0 33333
|
// NOTE: number like: 1 2.0 33333
|
||||||
|
|||||||
Reference in New Issue
Block a user