@remoteoss/json-schema-form 0.11.9-dev.20241210213029 → 0.11.10-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ #### 0.11.10-beta.0 (2025-01-22)
2
+
3
+ ##### Bug Fixes
4
+
5
+ * **checkbox:** Boolean - allow nullable values, and throw friendly error message ([#109](https://github.com/remoteoss/json-schema-form/pull/109)) ([63286eee](https://github.com/remoteoss/json-schema-form/commit/63286eee57591b97c9c5bbbcfbf9231cfabde864))
6
+
7
+ ##### Chores
8
+
9
+ * **conditionals:** Highlight bugs related to validations and conditional fields ([#107](https://github.com/remoteoss/json-schema-form/pull/107)) ([85dc3d6d](https://github.com/remoteoss/json-schema-form/commit/85dc3d6dbb0a0483a32479563ef9cd65cd36a210))
10
+ * Update eslint dependencies ([#99](https://github.com/remoteoss/json-schema-form/pull/99)) ([ff2e6ed5](https://github.com/remoteoss/json-schema-form/commit/ff2e6ed56ba96d911ccc36dc50485d8cb6ec764b))
11
+
12
+
13
+
14
+ ##### Build System / Dependencies
15
+
16
+ * **next:**
17
+ * Add build step ([#110](https://github.com/remoteoss/json-schema-form/pull/110)) ([6c00ce32](https://github.com/remoteoss/json-schema-form/commit/6c00ce32f6e5edba328d5cdede38a82c330f5f14))
18
+ * Set up lint ([#108](https://github.com/remoteoss/json-schema-form/pull/108)) ([038efcfc](https://github.com/remoteoss/json-schema-form/commit/038efcfcda6cb7b31852e7bc80c9524bffdb94f5))
19
+
20
+
21
+ #### 0.11.9-beta.0 (2024-12-17)
22
+
23
+ ##### Bug Fixes
24
+
25
+ * Add support for boolean values in the if condition ([#100](https://github.com/remoteoss/json-schema-form/pull/100)) ([b3dca67d](https://github.com/remoteoss/json-schema-form/commit/b3dca67da14a7e4f5339a14a1e2f14ac014d2b92))
26
+
1
27
  #### 0.11.8-beta.0 (2024-11-20)
2
28
 
3
29
  ##### Bug Fixes
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
- Copyright (c) 2024 Remote Technology, Inc.
4
- NPM Package: @remoteoss/json-schema-form@0.11.9-dev.20241210213029
5
- Generated: Tue, 10 Dec 2024 21:31:03 GMT
3
+ Copyright (c) 2025 Remote Technology, Inc.
4
+ NPM Package: @remoteoss/json-schema-form@0.11.10-beta.0
5
+ Generated: Wed, 22 Jan 2025 16:30:09 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -96,8 +96,11 @@ function hasProperty(object2, propertyName) {
96
96
  return Object.prototype.hasOwnProperty.call(object2, propertyName);
97
97
  }
98
98
 
99
- // src/checkIfConditionMatches.js
99
+ // src/internals/checkIfConditionMatches.js
100
100
  function checkIfConditionMatchesProperties(node, formValues, formFields, logic) {
101
+ if (typeof node.if === "boolean") {
102
+ return node.if;
103
+ }
101
104
  return Object.keys(node.if.properties ?? {}).every((name) => {
102
105
  const currentProperty = node.if.properties[name];
103
106
  const value = formValues[name];
@@ -554,7 +557,7 @@ var yupSchemas = {
554
557
  email: (0, import_yup.string)().trim().email("Please enter a valid email address").nullable(),
555
558
  fieldset: (0, import_yup.object)().nullable(),
556
559
  checkbox: (0, import_yup.string)().trim().nullable(),
557
- checkboxBool: (0, import_yup.boolean)(),
560
+ checkboxBool: (0, import_yup.boolean)().typeError('The value must be a boolean, but received "${value}"').nullable(),
558
561
  multiple: {
559
562
  select: (0, import_yup.array)().nullable(),
560
563
  "group-array": (0, import_yup.array)().nullable()
@@ -1278,9 +1281,6 @@ function updateField(field, requiredFields, node, formValues, logic, config) {
1278
1281
  }
1279
1282
  if (field.calculateConditionalProperties) {
1280
1283
  const { rootFieldAttrs, newAttributes } = field.calculateConditionalProperties({
1281
- dynamicAttributes: Object.fromEntries(
1282
- (field.dynamicAttributes ?? []).map((attr) => [attr, field[attr]])
1283
- ),
1284
1284
  isRequired: fieldIsRequired,
1285
1285
  conditionBranch: node,
1286
1286
  formValues
@@ -1316,7 +1316,7 @@ function processNode({
1316
1316
  parentID
1317
1317
  });
1318
1318
  });
1319
- if (node.if) {
1319
+ if (node.if !== void 0) {
1320
1320
  const matchesCondition = checkIfConditionMatchesProperties(node, formValues, formFields, logic);
1321
1321
  if (matchesCondition && node.then) {
1322
1322
  const { required: branchRequired } = processNode({
@@ -1597,18 +1597,15 @@ function rebuildFieldset(fields, property) {
1597
1597
  }));
1598
1598
  }
1599
1599
  function calculateConditionalProperties({ fieldParams, customProperties, logic, config }) {
1600
- return ({ dynamicAttributes, isRequired, conditionBranch, formValues }) => {
1600
+ return ({ isRequired, conditionBranch, formValues }) => {
1601
1601
  const conditionalProperty = conditionBranch?.properties?.[fieldParams.name];
1602
1602
  if (conditionalProperty) {
1603
1603
  const presentation = pickXKey(conditionalProperty, "presentation") ?? {};
1604
1604
  const fieldDescription = getFieldDescription(conditionalProperty, customProperties);
1605
- const newFieldParams = extractParametersFromNode(
1606
- {
1607
- ...conditionalProperty,
1608
- ...fieldDescription
1609
- },
1610
- Object.keys(dynamicAttributes)
1611
- );
1605
+ const newFieldParams = extractParametersFromNode({
1606
+ ...conditionalProperty,
1607
+ ...fieldDescription
1608
+ });
1612
1609
  let fieldSetFields;
1613
1610
  if (fieldParams.inputType === supportedTypes.FIELDSET) {
1614
1611
  fieldSetFields = rebuildFieldset(fieldParams.fields, conditionalProperty);
@@ -1628,7 +1625,6 @@ function calculateConditionalProperties({ fieldParams, customProperties, logic,
1628
1625
  ...calculatedComputedAttributes.value ? { value: calculatedComputedAttributes.value } : { value: void 0 },
1629
1626
  schema: buildYupSchema(
1630
1627
  {
1631
- ...dynamicAttributes,
1632
1628
  ...fieldParams,
1633
1629
  ...restNewFieldParams,
1634
1630
  ...calculatedComputedAttributes,
@@ -1771,32 +1767,11 @@ function convertJSONSchemaPropertiesToFieldParameters({ properties, required, "x
1771
1767
  return Object.entries(properties).filter(([, value]) => typeof value === "object").map(([key, value]) => buildFieldParameters(key, value, required, config)).sort(sortFields).map(({ position, ...fieldParams }) => fieldParams);
1772
1768
  }
1773
1769
  function applyFieldsDependencies(fieldsParameters, node) {
1774
- if (node?.properties) {
1775
- Object.entries(node.properties ?? {}).forEach(([key, value]) => {
1776
- if (value["x-jsf-logic-computedAttrs"]) {
1777
- const property = fieldsParameters.find(({ name }) => name === key);
1778
- property.isDynamic = true;
1779
- property.dynamicAttributes = [
1780
- ...property.dynamicAttributes ?? [],
1781
- ...Object.keys(value["x-jsf-logic-computedAttrs"])
1782
- ];
1783
- }
1784
- });
1785
- }
1786
1770
  if (node?.then) {
1787
1771
  fieldsParameters.filter(
1788
1772
  ({ name }) => node.then?.properties?.[name] || node.then?.required?.includes(name) || node.else?.properties?.[name] || node.else?.required?.includes(name)
1789
1773
  ).forEach((property) => {
1790
- const dynamicAttributes = [
1791
- ...Object.keys(node.then?.properties?.[property.name] ?? {}),
1792
- ...Object.keys(node.else?.properties?.[property.name] ?? {})
1793
- ];
1794
1774
  property.isDynamic = true;
1795
- if (property.dynamicAttributes) {
1796
- property.dynamicAttributes.push(...dynamicAttributes);
1797
- } else {
1798
- property.dynamicAttributes = dynamicAttributes;
1799
- }
1800
1775
  });
1801
1776
  applyFieldsDependencies(fieldsParameters, node.then);
1802
1777
  }
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
- Copyright (c) 2024 Remote Technology, Inc.
4
- NPM Package: @remoteoss/json-schema-form@0.11.9-dev.20241210213029
5
- Generated: Tue, 10 Dec 2024 21:31:03 GMT
3
+ Copyright (c) 2025 Remote Technology, Inc.
4
+ NPM Package: @remoteoss/json-schema-form@0.11.10-beta.0
5
+ Generated: Wed, 22 Jan 2025 16:30:09 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -59,8 +59,11 @@ function hasProperty(object2, propertyName) {
59
59
  return Object.prototype.hasOwnProperty.call(object2, propertyName);
60
60
  }
61
61
 
62
- // src/checkIfConditionMatches.js
62
+ // src/internals/checkIfConditionMatches.js
63
63
  function checkIfConditionMatchesProperties(node, formValues, formFields, logic) {
64
+ if (typeof node.if === "boolean") {
65
+ return node.if;
66
+ }
64
67
  return Object.keys(node.if.properties ?? {}).every((name) => {
65
68
  const currentProperty = node.if.properties[name];
66
69
  const value = formValues[name];
@@ -517,7 +520,7 @@ var yupSchemas = {
517
520
  email: string().trim().email("Please enter a valid email address").nullable(),
518
521
  fieldset: object().nullable(),
519
522
  checkbox: string().trim().nullable(),
520
- checkboxBool: boolean(),
523
+ checkboxBool: boolean().typeError('The value must be a boolean, but received "${value}"').nullable(),
521
524
  multiple: {
522
525
  select: array().nullable(),
523
526
  "group-array": array().nullable()
@@ -1241,9 +1244,6 @@ function updateField(field, requiredFields, node, formValues, logic, config) {
1241
1244
  }
1242
1245
  if (field.calculateConditionalProperties) {
1243
1246
  const { rootFieldAttrs, newAttributes } = field.calculateConditionalProperties({
1244
- dynamicAttributes: Object.fromEntries(
1245
- (field.dynamicAttributes ?? []).map((attr) => [attr, field[attr]])
1246
- ),
1247
1247
  isRequired: fieldIsRequired,
1248
1248
  conditionBranch: node,
1249
1249
  formValues
@@ -1279,7 +1279,7 @@ function processNode({
1279
1279
  parentID
1280
1280
  });
1281
1281
  });
1282
- if (node.if) {
1282
+ if (node.if !== void 0) {
1283
1283
  const matchesCondition = checkIfConditionMatchesProperties(node, formValues, formFields, logic);
1284
1284
  if (matchesCondition && node.then) {
1285
1285
  const { required: branchRequired } = processNode({
@@ -1560,18 +1560,15 @@ function rebuildFieldset(fields, property) {
1560
1560
  }));
1561
1561
  }
1562
1562
  function calculateConditionalProperties({ fieldParams, customProperties, logic, config }) {
1563
- return ({ dynamicAttributes, isRequired, conditionBranch, formValues }) => {
1563
+ return ({ isRequired, conditionBranch, formValues }) => {
1564
1564
  const conditionalProperty = conditionBranch?.properties?.[fieldParams.name];
1565
1565
  if (conditionalProperty) {
1566
1566
  const presentation = pickXKey(conditionalProperty, "presentation") ?? {};
1567
1567
  const fieldDescription = getFieldDescription(conditionalProperty, customProperties);
1568
- const newFieldParams = extractParametersFromNode(
1569
- {
1570
- ...conditionalProperty,
1571
- ...fieldDescription
1572
- },
1573
- Object.keys(dynamicAttributes)
1574
- );
1568
+ const newFieldParams = extractParametersFromNode({
1569
+ ...conditionalProperty,
1570
+ ...fieldDescription
1571
+ });
1575
1572
  let fieldSetFields;
1576
1573
  if (fieldParams.inputType === supportedTypes.FIELDSET) {
1577
1574
  fieldSetFields = rebuildFieldset(fieldParams.fields, conditionalProperty);
@@ -1591,7 +1588,6 @@ function calculateConditionalProperties({ fieldParams, customProperties, logic,
1591
1588
  ...calculatedComputedAttributes.value ? { value: calculatedComputedAttributes.value } : { value: void 0 },
1592
1589
  schema: buildYupSchema(
1593
1590
  {
1594
- ...dynamicAttributes,
1595
1591
  ...fieldParams,
1596
1592
  ...restNewFieldParams,
1597
1593
  ...calculatedComputedAttributes,
@@ -1734,32 +1730,11 @@ function convertJSONSchemaPropertiesToFieldParameters({ properties, required, "x
1734
1730
  return Object.entries(properties).filter(([, value]) => typeof value === "object").map(([key, value]) => buildFieldParameters(key, value, required, config)).sort(sortFields).map(({ position, ...fieldParams }) => fieldParams);
1735
1731
  }
1736
1732
  function applyFieldsDependencies(fieldsParameters, node) {
1737
- if (node?.properties) {
1738
- Object.entries(node.properties ?? {}).forEach(([key, value]) => {
1739
- if (value["x-jsf-logic-computedAttrs"]) {
1740
- const property = fieldsParameters.find(({ name }) => name === key);
1741
- property.isDynamic = true;
1742
- property.dynamicAttributes = [
1743
- ...property.dynamicAttributes ?? [],
1744
- ...Object.keys(value["x-jsf-logic-computedAttrs"])
1745
- ];
1746
- }
1747
- });
1748
- }
1749
1733
  if (node?.then) {
1750
1734
  fieldsParameters.filter(
1751
1735
  ({ name }) => node.then?.properties?.[name] || node.then?.required?.includes(name) || node.else?.properties?.[name] || node.else?.required?.includes(name)
1752
1736
  ).forEach((property) => {
1753
- const dynamicAttributes = [
1754
- ...Object.keys(node.then?.properties?.[property.name] ?? {}),
1755
- ...Object.keys(node.else?.properties?.[property.name] ?? {})
1756
- ];
1757
1737
  property.isDynamic = true;
1758
- if (property.dynamicAttributes) {
1759
- property.dynamicAttributes.push(...dynamicAttributes);
1760
- } else {
1761
- property.dynamicAttributes = dynamicAttributes;
1762
- }
1763
1738
  });
1764
1739
  applyFieldsDependencies(fieldsParameters, node.then);
1765
1740
  }
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
- Copyright (c) 2024 Remote Technology, Inc.
4
- NPM Package: @remoteoss/json-schema-form@0.11.9-dev.20241210213029
5
- Generated: Tue, 10 Dec 2024 21:31:03 GMT
3
+ Copyright (c) 2025 Remote Technology, Inc.
4
+ NPM Package: @remoteoss/json-schema-form@0.11.10-beta.0
5
+ Generated: Wed, 22 Jan 2025 16:30:09 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -11576,8 +11576,11 @@ function hasProperty(object2, propertyName) {
11576
11576
  return Object.prototype.hasOwnProperty.call(object2, propertyName);
11577
11577
  }
11578
11578
 
11579
- // src/checkIfConditionMatches.js
11579
+ // src/internals/checkIfConditionMatches.js
11580
11580
  function checkIfConditionMatchesProperties(node, formValues, formFields, logic) {
11581
+ if (typeof node.if === "boolean") {
11582
+ return node.if;
11583
+ }
11581
11584
  return Object.keys(node.if.properties ?? {}).every((name) => {
11582
11585
  const currentProperty = node.if.properties[name];
11583
11586
  const value = formValues[name];
@@ -12033,7 +12036,7 @@ var yupSchemas = {
12033
12036
  email: StringSchema().trim().email("Please enter a valid email address").nullable(),
12034
12037
  fieldset: ObjectSchema().nullable(),
12035
12038
  checkbox: StringSchema().trim().nullable(),
12036
- checkboxBool: boolean2(),
12039
+ checkboxBool: boolean2().typeError('The value must be a boolean, but received "${value}"').nullable(),
12037
12040
  multiple: {
12038
12041
  select: array_default().nullable(),
12039
12042
  "group-array": array_default().nullable()
@@ -12757,9 +12760,6 @@ function updateField(field, requiredFields, node, formValues, logic, config) {
12757
12760
  }
12758
12761
  if (field.calculateConditionalProperties) {
12759
12762
  const { rootFieldAttrs, newAttributes } = field.calculateConditionalProperties({
12760
- dynamicAttributes: Object.fromEntries(
12761
- (field.dynamicAttributes ?? []).map((attr) => [attr, field[attr]])
12762
- ),
12763
12763
  isRequired: fieldIsRequired,
12764
12764
  conditionBranch: node,
12765
12765
  formValues
@@ -12795,7 +12795,7 @@ function processNode({
12795
12795
  parentID
12796
12796
  });
12797
12797
  });
12798
- if (node.if) {
12798
+ if (node.if !== void 0) {
12799
12799
  const matchesCondition = checkIfConditionMatchesProperties(node, formValues, formFields, logic);
12800
12800
  if (matchesCondition && node.then) {
12801
12801
  const { required: branchRequired } = processNode({
@@ -13076,18 +13076,15 @@ function rebuildFieldset(fields, property2) {
13076
13076
  }));
13077
13077
  }
13078
13078
  function calculateConditionalProperties({ fieldParams, customProperties, logic, config }) {
13079
- return ({ dynamicAttributes, isRequired, conditionBranch, formValues }) => {
13079
+ return ({ isRequired, conditionBranch, formValues }) => {
13080
13080
  const conditionalProperty = conditionBranch?.properties?.[fieldParams.name];
13081
13081
  if (conditionalProperty) {
13082
13082
  const presentation = pickXKey(conditionalProperty, "presentation") ?? {};
13083
13083
  const fieldDescription = getFieldDescription(conditionalProperty, customProperties);
13084
- const newFieldParams = extractParametersFromNode(
13085
- {
13086
- ...conditionalProperty,
13087
- ...fieldDescription
13088
- },
13089
- Object.keys(dynamicAttributes)
13090
- );
13084
+ const newFieldParams = extractParametersFromNode({
13085
+ ...conditionalProperty,
13086
+ ...fieldDescription
13087
+ });
13091
13088
  let fieldSetFields;
13092
13089
  if (fieldParams.inputType === supportedTypes.FIELDSET) {
13093
13090
  fieldSetFields = rebuildFieldset(fieldParams.fields, conditionalProperty);
@@ -13107,7 +13104,6 @@ function calculateConditionalProperties({ fieldParams, customProperties, logic,
13107
13104
  ...calculatedComputedAttributes.value ? { value: calculatedComputedAttributes.value } : { value: void 0 },
13108
13105
  schema: buildYupSchema(
13109
13106
  {
13110
- ...dynamicAttributes,
13111
13107
  ...fieldParams,
13112
13108
  ...restNewFieldParams,
13113
13109
  ...calculatedComputedAttributes,
@@ -13250,32 +13246,11 @@ function convertJSONSchemaPropertiesToFieldParameters({ properties, required: re
13250
13246
  return Object.entries(properties).filter(([, value]) => typeof value === "object").map(([key, value]) => buildFieldParameters(key, value, required2, config)).sort(sortFields2).map(({ position, ...fieldParams }) => fieldParams);
13251
13247
  }
13252
13248
  function applyFieldsDependencies(fieldsParameters, node) {
13253
- if (node?.properties) {
13254
- Object.entries(node.properties ?? {}).forEach(([key, value]) => {
13255
- if (value["x-jsf-logic-computedAttrs"]) {
13256
- const property2 = fieldsParameters.find(({ name }) => name === key);
13257
- property2.isDynamic = true;
13258
- property2.dynamicAttributes = [
13259
- ...property2.dynamicAttributes ?? [],
13260
- ...Object.keys(value["x-jsf-logic-computedAttrs"])
13261
- ];
13262
- }
13263
- });
13264
- }
13265
13249
  if (node?.then) {
13266
13250
  fieldsParameters.filter(
13267
13251
  ({ name }) => node.then?.properties?.[name] || node.then?.required?.includes(name) || node.else?.properties?.[name] || node.else?.required?.includes(name)
13268
13252
  ).forEach((property2) => {
13269
- const dynamicAttributes = [
13270
- ...Object.keys(node.then?.properties?.[property2.name] ?? {}),
13271
- ...Object.keys(node.else?.properties?.[property2.name] ?? {})
13272
- ];
13273
13253
  property2.isDynamic = true;
13274
- if (property2.dynamicAttributes) {
13275
- property2.dynamicAttributes.push(...dynamicAttributes);
13276
- } else {
13277
- property2.dynamicAttributes = dynamicAttributes;
13278
- }
13279
13254
  });
13280
13255
  applyFieldsDependencies(fieldsParameters, node.then);
13281
13256
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remoteoss/json-schema-form",
3
- "version": "0.11.9-dev.20241210213029",
3
+ "version": "0.11.10-beta.0",
4
4
  "description": "Headless UI form powered by JSON Schemas",
5
5
  "author": "Remote.com <engineering@remote.com> (https://remote.com/)",
6
6
  "license": "MIT",
@@ -54,8 +54,8 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/core": "^7.21.5",
57
+ "@babel/eslint-parser": "^7.25.9",
57
58
  "@babel/preset-env": "^7.21.5",
58
- "babel-eslint": "^10.1.0",
59
59
  "babel-jest": "^29.5.0",
60
60
  "child-process-promise": "^2.2.1",
61
61
  "esbuild": "^0.17.15",
@@ -1,51 +1,65 @@
1
- import { checkIfConditionMatchesProperties } from '../checkIfConditionMatches';
1
+ import { checkIfConditionMatchesProperties } from '../internals/checkIfConditionMatches';
2
2
 
3
- it('Empty if is always going to be true', () => {
4
- expect(checkIfConditionMatchesProperties({ if: { properties: {} } })).toBe(true);
5
- });
3
+ describe('checkIfConditionMatchesProperties()', () => {
4
+ it('True if is always going to be true', () => {
5
+ expect(checkIfConditionMatchesProperties({ if: true })).toBe(true);
6
+ });
6
7
 
7
- it('Basic if check passes with correct value', () => {
8
- expect(
9
- checkIfConditionMatchesProperties(
10
- { if: { properties: { a: { const: 'hello' } } } },
11
- {
12
- a: 'hello',
13
- }
14
- )
15
- ).toBe(true);
16
- });
8
+ it('False if is always going to be false', () => {
9
+ expect(checkIfConditionMatchesProperties({ if: false })).toBe(false);
10
+ });
17
11
 
18
- it('Basic if check fails with incorrect value', () => {
19
- expect(
20
- checkIfConditionMatchesProperties(
21
- { if: { properties: { a: { const: 'hello' } } } },
22
- {
23
- a: 'goodbye',
24
- }
25
- )
26
- ).toBe(false);
27
- });
12
+ it('Empty if is always going to be true', () => {
13
+ expect(checkIfConditionMatchesProperties({ if: { properties: {} } })).toBe(true);
14
+ });
28
15
 
29
- it('Nested properties check passes with correct value', () => {
30
- expect(
31
- checkIfConditionMatchesProperties(
32
- { if: { properties: { parent: { properties: { child: { const: 'hello from child' } } } } } },
33
- {
34
- parent: { child: 'hello from child' },
35
- },
36
- [{ name: 'parent', fields: [] }]
37
- )
38
- ).toBe(true);
39
- });
16
+ it('Basic if check passes with correct value', () => {
17
+ expect(
18
+ checkIfConditionMatchesProperties(
19
+ { if: { properties: { a: { const: 'hello' } } } },
20
+ {
21
+ a: 'hello',
22
+ }
23
+ )
24
+ ).toBe(true);
25
+ });
26
+
27
+ it('Basic if check fails with incorrect value', () => {
28
+ expect(
29
+ checkIfConditionMatchesProperties(
30
+ { if: { properties: { a: { const: 'hello' } } } },
31
+ {
32
+ a: 'goodbye',
33
+ }
34
+ )
35
+ ).toBe(false);
36
+ });
37
+
38
+ it('Nested properties check passes with correct value', () => {
39
+ expect(
40
+ checkIfConditionMatchesProperties(
41
+ {
42
+ if: { properties: { parent: { properties: { child: { const: 'hello from child' } } } } },
43
+ },
44
+ {
45
+ parent: { child: 'hello from child' },
46
+ },
47
+ [{ name: 'parent', fields: [] }]
48
+ )
49
+ ).toBe(true);
50
+ });
40
51
 
41
- it('Nested properties check passes with correct value', () => {
42
- expect(
43
- checkIfConditionMatchesProperties(
44
- { if: { properties: { parent: { properties: { child: { const: 'hello from child' } } } } } },
45
- {
46
- parent: { child: 'goodbye from child' },
47
- },
48
- [{ name: 'parent', fields: [] }]
49
- )
50
- ).toBe(false);
52
+ it('Nested properties check passes with correct value', () => {
53
+ expect(
54
+ checkIfConditionMatchesProperties(
55
+ {
56
+ if: { properties: { parent: { properties: { child: { const: 'hello from child' } } } } },
57
+ },
58
+ {
59
+ parent: { child: 'goodbye from child' },
60
+ },
61
+ [{ name: 'parent', fields: [] }]
62
+ )
63
+ ).toBe(false);
64
+ });
51
65
  });