Skip to content

Commit 06154b1

Browse files
committed
fix #280
1 parent 7c72ecb commit 06154b1

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

packages/core/src/utils/Literal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function isLiteral(literal: unknown): literal is MBLiteral {
7171
* @param literal
7272
*/
7373
export function parseUnknownToLiteralArray(literal: unknown): MBLiteral[] | undefined {
74-
if (literal === undefined) {
74+
if (literal === undefined || literal === null) {
7575
return undefined;
7676
}
7777

tests/fields/IPF.test.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,12 @@ let TEST_CONFIG: IPFTest[] = [
152152
testCases: [
153153
{
154154
declaration: `INPUT[${InputFieldType.MULTI_SELECT}(${STANDARD_OPTION_ARGUMENTS}):${TEST_PROP}]`,
155-
validValues: [...STANDARD_OPTION_VALUES_ARRAY, [TEST_VALUES.STRING], [TEST_VALUES.EMPTY_STRING]],
156-
validMappedValues: [[TEST_VALUES.NULL, [TEST_VALUES.NULL]]],
157-
invalidValues: [TEST_VALUES.UNDEFINED, TEST_VALUES.OBJECT],
155+
validValues: STANDARD_OPTION_VALUES_ARRAY,
156+
validMappedValues: [
157+
[TEST_VALUES.STRING, [TEST_VALUES.STRING]],
158+
[TEST_VALUES.EMPTY_STRING, [TEST_VALUES.EMPTY_STRING]],
159+
],
160+
invalidValues: [TEST_VALUES.NULL, TEST_VALUES.UNDEFINED, TEST_VALUES.OBJECT],
158161
},
159162
],
160163
},
@@ -275,11 +278,10 @@ let TEST_CONFIG: IPFTest[] = [
275278
declaration: `INPUT[${InputFieldType.LIST}:${TEST_PROP}]`,
276279
validValues: STANDARD_OPTION_VALUES_ARRAY,
277280
validMappedValues: [
278-
[TEST_VALUES.NULL, [TEST_VALUES.NULL]],
279281
[TEST_VALUES.STRING, [TEST_VALUES.STRING]],
280282
[TEST_VALUES.EMPTY_STRING, [TEST_VALUES.EMPTY_STRING]],
281283
],
282-
invalidValues: [TEST_VALUES.UNDEFINED, TEST_VALUES.OBJECT],
284+
invalidValues: [TEST_VALUES.NULL, TEST_VALUES.UNDEFINED, TEST_VALUES.OBJECT],
283285
},
284286
],
285287
},
@@ -290,11 +292,10 @@ let TEST_CONFIG: IPFTest[] = [
290292
declaration: `INPUT[${InputFieldType.LIST_SUGGESTER}(${STANDARD_OPTION_ARGUMENTS}):${TEST_PROP}]`,
291293
validValues: STANDARD_OPTION_VALUES_ARRAY,
292294
validMappedValues: [
293-
[TEST_VALUES.NULL, [TEST_VALUES.NULL]],
294295
[TEST_VALUES.STRING, [TEST_VALUES.STRING]],
295296
[TEST_VALUES.EMPTY_STRING, [TEST_VALUES.EMPTY_STRING]],
296297
],
297-
invalidValues: [TEST_VALUES.UNDEFINED, TEST_VALUES.OBJECT],
298+
invalidValues: [TEST_VALUES.NULL, TEST_VALUES.UNDEFINED, TEST_VALUES.OBJECT],
298299
},
299300
],
300301
},
@@ -343,11 +344,10 @@ let TEST_CONFIG: IPFTest[] = [
343344
declaration: `INPUT[${InputFieldType.INLINE_LIST_SUGGESTER}(${STANDARD_OPTION_ARGUMENTS}):${TEST_PROP}]`,
344345
validValues: STANDARD_OPTION_VALUES_ARRAY,
345346
validMappedValues: [
346-
[TEST_VALUES.NULL, [TEST_VALUES.NULL]],
347347
[TEST_VALUES.STRING, [TEST_VALUES.STRING]],
348348
[TEST_VALUES.EMPTY_STRING, [TEST_VALUES.EMPTY_STRING]],
349349
],
350-
invalidValues: [TEST_VALUES.UNDEFINED, TEST_VALUES.OBJECT],
350+
invalidValues: [TEST_VALUES.NULL, TEST_VALUES.UNDEFINED, TEST_VALUES.OBJECT],
351351
},
352352
],
353353
},
@@ -358,11 +358,10 @@ let TEST_CONFIG: IPFTest[] = [
358358
declaration: `INPUT[${InputFieldType.INLINE_LIST}:${TEST_PROP}]`,
359359
validValues: STANDARD_OPTION_VALUES_ARRAY,
360360
validMappedValues: [
361-
[TEST_VALUES.NULL, [TEST_VALUES.NULL]],
362361
[TEST_VALUES.STRING, [TEST_VALUES.STRING]],
363362
[TEST_VALUES.EMPTY_STRING, [TEST_VALUES.EMPTY_STRING]],
364363
],
365-
invalidValues: [TEST_VALUES.UNDEFINED, TEST_VALUES.OBJECT],
364+
invalidValues: [TEST_VALUES.NULL, TEST_VALUES.UNDEFINED, TEST_VALUES.OBJECT],
366365
},
367366
],
368367
},
@@ -373,11 +372,10 @@ let TEST_CONFIG: IPFTest[] = [
373372
declaration: `INPUT[${InputFieldType.INLINE_LIST_SUGGESTER}:${TEST_PROP}]`,
374373
validValues: STANDARD_OPTION_VALUES_ARRAY,
375374
validMappedValues: [
376-
[TEST_VALUES.NULL, [TEST_VALUES.NULL]],
377375
[TEST_VALUES.STRING, [TEST_VALUES.STRING]],
378376
[TEST_VALUES.EMPTY_STRING, [TEST_VALUES.EMPTY_STRING]],
379377
],
380-
invalidValues: [TEST_VALUES.UNDEFINED, TEST_VALUES.OBJECT],
378+
invalidValues: [TEST_VALUES.NULL, TEST_VALUES.UNDEFINED, TEST_VALUES.OBJECT],
381379
},
382380
],
383381
},

tests/utils/Literal.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ describe('isLiteral function', () => {
108108
describe('parseUnknownToLiteralArray function', () => {
109109
test('should return undefined when given undefined', () => {
110110
expect(parseUnknownToLiteralArray(undefined)).toBeUndefined();
111+
expect(parseUnknownToLiteralArray(null)).toBeUndefined();
111112
});
112113

113114
test('should return an array with one element when given a literal', () => {
@@ -116,7 +117,6 @@ describe('parseUnknownToLiteralArray function', () => {
116117
expect(parseUnknownToLiteralArray(123)).toEqual([123]);
117118
expect(parseUnknownToLiteralArray(-123.45)).toEqual([-123.45]);
118119
expect(parseUnknownToLiteralArray('hello')).toEqual(['hello']);
119-
expect(parseUnknownToLiteralArray(null)).toEqual([null]);
120120
});
121121

122122
test('should return an array with all literals when given an array with literals', () => {

0 commit comments

Comments
 (0)