diff --git a/package-lock.json b/package-lock.json
index cbff4f7c5b..e84b2988fe 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4342,27 +4342,6 @@
"@types/react": "*"
}
},
- "@types/redux-logger": {
- "version": "3.0.6",
- "resolved": "https://registry.npmjs.org/@types/redux-logger/-/redux-logger-3.0.6.tgz",
- "integrity": "sha512-HXVJnbyuTcVtQ+qiwDcbLEMoOgNjKnNYVKx29P4NhV+FIgVVRCFILEPzjgSxlmMLc6aBVaEew7PfE3421DZ6Jw==",
- "requires": {
- "redux": "^3.6.0"
- },
- "dependencies": {
- "redux": {
- "version": "3.7.2",
- "resolved": "https://registry.npmjs.org/redux/-/redux-3.7.2.tgz",
- "integrity": "sha512-pNqnf9q1hI5HHZRBkj3bAngGZW/JMCmexDlOxw4XagXY2o1327nHH54LoTjiPJ0gizoqPDRqWyX/00g0hD6w+A==",
- "requires": {
- "lodash": "^4.2.1",
- "lodash-es": "^4.2.1",
- "loose-envify": "^1.1.0",
- "symbol-observable": "^1.0.3"
- }
- }
- }
- },
"@types/redux-mock-store": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@types/redux-mock-store/-/redux-mock-store-1.0.2.tgz",
@@ -4720,15 +4699,6 @@
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz",
"integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw=="
},
- "ansi-styles": {
- "version": "4.3.0",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
- "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
- "optional": true,
- "requires": {
- "color-convert": "^2.0.1"
- }
- },
"array-union": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz",
@@ -4769,52 +4739,6 @@
}
}
},
- "chalk": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz",
- "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==",
- "optional": true,
- "requires": {
- "ansi-styles": "^4.1.0",
- "supports-color": "^7.1.0"
- }
- },
- "color-convert": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
- "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "optional": true,
- "requires": {
- "color-name": "~1.1.4"
- }
- },
- "color-name": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
- "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
- "optional": true
- },
- "cosmiconfig": {
- "version": "6.0.0",
- "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-6.0.0.tgz",
- "integrity": "sha512-xb3ZL6+L8b9JLLCx3ZdoZy4+2ECphCMo2PwqgP1tlfVq6M6YReyzBJtvWWtbDSpNr9hn96pkCiZqUcFEc+54Qg==",
- "optional": true,
- "requires": {
- "@types/parse-json": "^4.0.0",
- "import-fresh": "^3.1.0",
- "parse-json": "^5.0.0",
- "path-type": "^4.0.0",
- "yaml": "^1.7.2"
- },
- "dependencies": {
- "path-type": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
- "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
- "optional": true
- }
- }
- },
"dir-glob": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-2.2.2.tgz",
@@ -4857,37 +4781,6 @@
}
}
},
- "fork-ts-checker-webpack-plugin-v5": {
- "version": "npm:fork-ts-checker-webpack-plugin@5.2.1",
- "resolved": "https://registry.npmjs.org/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-5.2.1.tgz",
- "integrity": "sha512-SVi+ZAQOGbtAsUWrZvGzz38ga2YqjWvca1pXQFUArIVXqli0lLoDQ8uS0wg0kSpcwpZmaW5jVCZXQebkyUQSsw==",
- "optional": true,
- "requires": {
- "@babel/code-frame": "^7.8.3",
- "@types/json-schema": "^7.0.5",
- "chalk": "^4.1.0",
- "cosmiconfig": "^6.0.0",
- "deepmerge": "^4.2.2",
- "fs-extra": "^9.0.0",
- "memfs": "^3.1.2",
- "minimatch": "^3.0.4",
- "schema-utils": "2.7.0",
- "semver": "^7.3.2",
- "tapable": "^1.0.0"
- }
- },
- "fs-extra": {
- "version": "9.1.0",
- "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
- "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
- "optional": true,
- "requires": {
- "at-least-node": "^1.0.0",
- "graceful-fs": "^4.2.0",
- "jsonfile": "^6.0.1",
- "universalify": "^2.0.0"
- }
- },
"glob-parent": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz",
@@ -4922,27 +4815,11 @@
"slash": "^2.0.0"
}
},
- "has-flag": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
- "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
- "optional": true
- },
"ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
"integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg=="
},
- "import-fresh": {
- "version": "3.3.0",
- "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz",
- "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==",
- "optional": true,
- "requires": {
- "parent-module": "^1.0.0",
- "resolve-from": "^4.0.0"
- }
- },
"is-number": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz",
@@ -4961,25 +4838,6 @@
}
}
},
- "jsonfile": {
- "version": "6.1.0",
- "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
- "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
- "optional": true,
- "requires": {
- "graceful-fs": "^4.1.6",
- "universalify": "^2.0.0"
- }
- },
- "lru-cache": {
- "version": "6.0.0",
- "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
- "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
- "optional": true,
- "requires": {
- "yallist": "^4.0.0"
- }
- },
"micromatch": {
"version": "3.1.10",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz",
@@ -5000,18 +4858,6 @@
"to-regex": "^3.0.2"
}
},
- "parse-json": {
- "version": "5.2.0",
- "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz",
- "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==",
- "optional": true,
- "requires": {
- "@babel/code-frame": "^7.0.0",
- "error-ex": "^1.3.1",
- "json-parse-even-better-errors": "^2.3.0",
- "lines-and-columns": "^1.1.6"
- }
- },
"path-type": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz",
@@ -5027,46 +4873,11 @@
}
}
},
- "resolve-from": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
- "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
- "optional": true
- },
- "schema-utils": {
- "version": "2.7.0",
- "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.0.tgz",
- "integrity": "sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A==",
- "optional": true,
- "requires": {
- "@types/json-schema": "^7.0.4",
- "ajv": "^6.12.2",
- "ajv-keywords": "^3.4.1"
- }
- },
- "semver": {
- "version": "7.3.5",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
- "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
- "optional": true,
- "requires": {
- "lru-cache": "^6.0.0"
- }
- },
"slash": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz",
"integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A=="
},
- "supports-color": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
- "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
- "optional": true,
- "requires": {
- "has-flag": "^4.0.0"
- }
- },
"to-regex-range": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz",
@@ -5075,18 +4886,6 @@
"is-number": "^3.0.0",
"repeat-string": "^1.6.1"
}
- },
- "universalify": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
- "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==",
- "optional": true
- },
- "yallist": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
- "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
- "optional": true
}
}
},
@@ -5305,16 +5104,6 @@
"unique-filename": "^1.1.1"
}
},
- "chalk": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz",
- "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==",
- "optional": true,
- "requires": {
- "ansi-styles": "^4.1.0",
- "supports-color": "^7.1.0"
- }
- },
"cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
@@ -5469,17 +5258,6 @@
"supports-color": "^7.0.0"
}
},
- "loader-utils": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz",
- "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==",
- "optional": true,
- "requires": {
- "big.js": "^5.2.2",
- "emojis-list": "^3.0.0",
- "json5": "^2.1.2"
- }
- },
"lru-cache": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
@@ -5614,17 +5392,6 @@
"repeat-string": "^1.6.1"
}
},
- "vue-loader-v16": {
- "version": "npm:vue-loader@16.3.3",
- "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.3.3.tgz",
- "integrity": "sha512-/1GzCuQ6MRORbC+leKTKoTGtpQt60bYe0gDGEextSteA2OM+v201FPha5jzmjQzVhRcwieZeUvezAtG5a/e5cw==",
- "optional": true,
- "requires": {
- "chalk": "^4.1.0",
- "hash-sum": "^2.0.0",
- "loader-utils": "^2.0.0"
- }
- },
"wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
@@ -12600,6 +12367,180 @@
}
}
},
+ "fork-ts-checker-webpack-plugin-v5": {
+ "version": "npm:fork-ts-checker-webpack-plugin@5.2.1",
+ "resolved": "https://registry.npmjs.org/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-5.2.1.tgz",
+ "integrity": "sha512-SVi+ZAQOGbtAsUWrZvGzz38ga2YqjWvca1pXQFUArIVXqli0lLoDQ8uS0wg0kSpcwpZmaW5jVCZXQebkyUQSsw==",
+ "optional": true,
+ "requires": {
+ "@babel/code-frame": "^7.8.3",
+ "@types/json-schema": "^7.0.5",
+ "chalk": "^4.1.0",
+ "cosmiconfig": "^6.0.0",
+ "deepmerge": "^4.2.2",
+ "fs-extra": "^9.0.0",
+ "memfs": "^3.1.2",
+ "minimatch": "^3.0.4",
+ "schema-utils": "2.7.0",
+ "semver": "^7.3.2",
+ "tapable": "^1.0.0"
+ },
+ "dependencies": {
+ "ansi-styles": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+ "optional": true,
+ "requires": {
+ "color-convert": "^2.0.1"
+ }
+ },
+ "chalk": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
+ "optional": true,
+ "requires": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ }
+ },
+ "color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "optional": true,
+ "requires": {
+ "color-name": "~1.1.4"
+ }
+ },
+ "color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+ "optional": true
+ },
+ "cosmiconfig": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-6.0.0.tgz",
+ "integrity": "sha512-xb3ZL6+L8b9JLLCx3ZdoZy4+2ECphCMo2PwqgP1tlfVq6M6YReyzBJtvWWtbDSpNr9hn96pkCiZqUcFEc+54Qg==",
+ "optional": true,
+ "requires": {
+ "@types/parse-json": "^4.0.0",
+ "import-fresh": "^3.1.0",
+ "parse-json": "^5.0.0",
+ "path-type": "^4.0.0",
+ "yaml": "^1.7.2"
+ }
+ },
+ "fs-extra": {
+ "version": "9.1.0",
+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
+ "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
+ "optional": true,
+ "requires": {
+ "at-least-node": "^1.0.0",
+ "graceful-fs": "^4.2.0",
+ "jsonfile": "^6.0.1",
+ "universalify": "^2.0.0"
+ }
+ },
+ "has-flag": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+ "optional": true
+ },
+ "import-fresh": {
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz",
+ "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==",
+ "optional": true,
+ "requires": {
+ "parent-module": "^1.0.0",
+ "resolve-from": "^4.0.0"
+ }
+ },
+ "jsonfile": {
+ "version": "6.1.0",
+ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
+ "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
+ "optional": true,
+ "requires": {
+ "graceful-fs": "^4.1.6",
+ "universalify": "^2.0.0"
+ }
+ },
+ "lru-cache": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
+ "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
+ "optional": true,
+ "requires": {
+ "yallist": "^4.0.0"
+ }
+ },
+ "parse-json": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz",
+ "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==",
+ "optional": true,
+ "requires": {
+ "@babel/code-frame": "^7.0.0",
+ "error-ex": "^1.3.1",
+ "json-parse-even-better-errors": "^2.3.0",
+ "lines-and-columns": "^1.1.6"
+ }
+ },
+ "resolve-from": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
+ "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
+ "optional": true
+ },
+ "schema-utils": {
+ "version": "2.7.0",
+ "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.0.tgz",
+ "integrity": "sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A==",
+ "optional": true,
+ "requires": {
+ "@types/json-schema": "^7.0.4",
+ "ajv": "^6.12.2",
+ "ajv-keywords": "^3.4.1"
+ }
+ },
+ "semver": {
+ "version": "7.3.5",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
+ "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
+ "optional": true,
+ "requires": {
+ "lru-cache": "^6.0.0"
+ }
+ },
+ "supports-color": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+ "optional": true,
+ "requires": {
+ "has-flag": "^4.0.0"
+ }
+ },
+ "universalify": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
+ "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==",
+ "optional": true
+ },
+ "yallist": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
+ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
+ "optional": true
+ }
+ }
+ },
"form-data": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
@@ -17092,11 +17033,6 @@
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
- "lodash-es": {
- "version": "4.17.21",
- "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz",
- "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw=="
- },
"lodash._reinterpolate": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz",
@@ -17490,9 +17426,9 @@
}
},
"memfs": {
- "version": "3.2.2",
- "resolved": "https://registry.npmjs.org/memfs/-/memfs-3.2.2.tgz",
- "integrity": "sha512-RE0CwmIM3CEvpcdK3rZ19BC4E6hv9kADkMN5rPduRak58cNArWLi/9jFLsa4rhsjfVxMP3v0jO7FHXq7SvFY5Q==",
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/memfs/-/memfs-3.3.0.tgz",
+ "integrity": "sha512-BEE62uMfKOavX3iG7GYX43QJ+hAeeWnwIAuJ/R6q96jaMtiLzhsxHJC8B1L7fK7Pt/vXDRwb3SG/yBpNGDPqzg==",
"optional": true,
"requires": {
"fs-monkey": "1.0.3"
@@ -25054,6 +24990,79 @@
}
}
},
+ "vue-loader-v16": {
+ "version": "npm:vue-loader@16.8.1",
+ "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.8.1.tgz",
+ "integrity": "sha512-V53TJbHmzjBhCG5OYI2JWy/aYDspz4oVHKxS43Iy212GjGIG1T3EsB3+GWXFm/1z5VwjdjLmdZUFYM70y77vtQ==",
+ "optional": true,
+ "requires": {
+ "chalk": "^4.1.0",
+ "hash-sum": "^2.0.0",
+ "loader-utils": "^2.0.0"
+ },
+ "dependencies": {
+ "ansi-styles": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+ "optional": true,
+ "requires": {
+ "color-convert": "^2.0.1"
+ }
+ },
+ "chalk": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
+ "optional": true,
+ "requires": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ }
+ },
+ "color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "optional": true,
+ "requires": {
+ "color-name": "~1.1.4"
+ }
+ },
+ "color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+ "optional": true
+ },
+ "has-flag": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+ "optional": true
+ },
+ "loader-utils": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz",
+ "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==",
+ "optional": true,
+ "requires": {
+ "big.js": "^5.2.2",
+ "emojis-list": "^3.0.0",
+ "json5": "^2.1.2"
+ }
+ },
+ "supports-color": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+ "optional": true,
+ "requires": {
+ "has-flag": "^4.0.0"
+ }
+ }
+ }
+ },
"vue-style-loader": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.3.tgz",
diff --git a/packages/angular-material/package.json b/packages/angular-material/package.json
index a33e545815..c7dab9770c 100644
--- a/packages/angular-material/package.json
+++ b/packages/angular-material/package.json
@@ -90,7 +90,6 @@
"@jsonforms/core": "^3.0.0-alpha.1",
"@jsonforms/examples": "^3.0.0-alpha.1",
"@types/node": "^10.10.0",
- "@types/redux-logger": "3.0.6",
"angular2-template-loader": "^0.6.2",
"copy-webpack-plugin": "^5.0.5",
"core-js": "^2.5.3",
diff --git a/packages/angular-test/package.json b/packages/angular-test/package.json
index d891fe4daa..7869ddce63 100644
--- a/packages/angular-test/package.json
+++ b/packages/angular-test/package.json
@@ -5,8 +5,7 @@
"main": "./lib/index.js",
"dependencies": {
"@jsonforms/angular": "^3.0.0-alpha.1",
- "@jsonforms/core": "^3.0.0-alpha.1",
- "redux": "^4.0.4"
+ "@jsonforms/core": "^3.0.0-alpha.1"
},
"devDependencies": {
"jasmine": "^3.2.0",
diff --git a/packages/vanilla/package.json b/packages/vanilla/package.json
index 883d9a3fee..1ba71198dd 100644
--- a/packages/vanilla/package.json
+++ b/packages/vanilla/package.json
@@ -53,7 +53,6 @@
"jsdom-global": "^3.0.2",
"nyc": "^14.1.1",
"react-dom": "^16.12.0",
- "react-redux": "^7.1.3",
"rimraf": "^3.0.2",
"source-map-loader": "^0.2.4",
"source-map-support": "0.5.16",
diff --git a/packages/vanilla/src/styles/styles.ts b/packages/vanilla/src/styles/styles.ts
index ae0826c30d..65f014a1a8 100644
--- a/packages/vanilla/src/styles/styles.ts
+++ b/packages/vanilla/src/styles/styles.ts
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2021 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -77,6 +77,10 @@ export const vanillaStyles: StyleDef[] = [
name: 'category.group',
classNames: ['category-group']
},
+ {
+ name: 'category.subcategories',
+ classNames: ['category-subcategories']
+ },
{
name: 'array.layout',
classNames: ['array-layout']
diff --git a/packages/vanilla/test/renderers/ArrayControl.test.tsx b/packages/vanilla/test/renderers/ArrayControl.test.tsx
index 76603ed845..1e6d6a662c 100644
--- a/packages/vanilla/test/renderers/ArrayControl.test.tsx
+++ b/packages/vanilla/test/renderers/ArrayControl.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,12 +22,11 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
import * as React from 'react';
-import { Provider } from 'react-redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import ArrayControl from '../../src/complex/array/ArrayControlRenderer';
import { vanillaRenderers } from '../../src/index';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore } from '../util';
import IntegerCell, { integerCellTester } from '../../src/cells/IntegerCell';
import Adapter from 'enzyme-adapter-react-16';
@@ -62,26 +61,15 @@ const fixture = {
describe('Array control renderer', () => {
test('render two children', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema,
- renderers: vanillaRenderers,
- cells: [
- {
- tester: integerCellTester, cell: IntegerCell
- }
- ]
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
+ const cells = [{ tester: integerCellTester, cell: IntegerCell }];
const wrapper = mount(
-
-
-
-
-
+
+
+
);
const controls = wrapper.find('.control');
diff --git a/packages/vanilla/test/renderers/BooleanCell.test.tsx b/packages/vanilla/test/renderers/BooleanCell.test.tsx
index 62e5f502f0..94206e12bd 100644
--- a/packages/vanilla/test/renderers/BooleanCell.test.tsx
+++ b/packages/vanilla/test/renderers/BooleanCell.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -26,18 +26,15 @@
import * as React from 'react';
import {
ControlElement,
- getData,
HorizontalLayout,
JsonSchema,
- update
} from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
-import { Provider } from 'react-redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import BooleanCell, { booleanCellTester } from '../../src/cells/BooleanCell';
import HorizontalLayoutRenderer from '../../src/layouts/HorizontalLayout';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore, TestEmitter } from '../util';
import { vanillaRenderers } from '../../src';
import { InputControl } from '../../src/controls/InputControl';
@@ -160,18 +157,11 @@ describe('Boolean cell', () => {
firstBooleanCell: true,
secondBooleanCell: false
};
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema,
- renderers: vanillaRenderers
- });
+ const core = initCore(schema, uischema, data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const inputs = wrapper.find(InputControl);
expect(inputs.at(0).is(':focus')).toBe(false);
@@ -186,17 +176,11 @@ describe('Boolean cell', () => {
focus: true
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
expect(input.is(':focus')).toBe(true);
@@ -210,17 +194,11 @@ describe('Boolean cell', () => {
focus: false
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
@@ -231,34 +209,22 @@ describe('Boolean cell', () => {
type: 'Control',
scope: '#/properties/foo'
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode();
expect(document.activeElement).not.toBe(input);
});
test('render', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
@@ -267,17 +233,11 @@ describe('Boolean cell', () => {
});
test('has classes set', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
expect(input.hasClass('input')).toBe(true);
@@ -286,163 +246,137 @@ describe('Boolean cell', () => {
});
test('update via input event', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const input = wrapper.find('input');
input.simulate('change', { target: { checked: false } });
- expect(getData(store.getState()).foo).toBe(false);
+ expect(onChangeData.data.foo).toBe(false);
});
test('update via action', () => {
const data = { foo: false };
- const store = initJsonFormsVanillaStore({
- data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, data);
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
- store.dispatch(update('foo', () => false));
+ core.data = { ...core.data, foo: false };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core }} );
+ wrapper.update();
expect(input.checked).toBe(false);
- expect(getData(store.getState()).foo).toBe(false);
+ expect(onChangeData.data.foo).toBe(false);
});
test.skip('update with undefined value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
- store.dispatch(update('foo', () => undefined));
+ core.data = { ...core.data, foo: undefined };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core }} );
+ wrapper.update();
expect(input.value).toEqual('');
});
test.skip('update with null value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
- store.dispatch(update('foo', () => null));
+ core.data = { ...core.data, foo: null };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core }} );
+ wrapper.update();
expect(input.value).toEqual('');
});
test('update with wrong ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
- store.dispatch(update('bar', () => 11));
+ core.data = { ...core.data, bar: 11 };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core }} );
+ wrapper.update();
expect(input.props().checked).toBe(true);
});
test('update with null ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
- store.dispatch(update(null, () => false));
+ core.data = { ...core.data, null: false };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core }} );
+ wrapper.update();
expect(input.checked).toBe(true);
});
test('update with undefined ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update(undefined, () => false));
+ core.data = { ...core.data, undefined: false };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.checked).toBe(true);
});
test('disable', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.disabled).toBe(true);
});
test('enabled by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.disabled).toBe(false);
diff --git a/packages/vanilla/test/renderers/CategorizationRenderer.test.tsx b/packages/vanilla/test/renderers/CategorizationRenderer.test.tsx
index bafdc746a8..4a2ed080ce 100644
--- a/packages/vanilla/test/renderers/CategorizationRenderer.test.tsx
+++ b/packages/vanilla/test/renderers/CategorizationRenderer.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,7 +23,6 @@
THE SOFTWARE.
*/
import * as React from 'react';
-import { Provider } from 'react-redux';
import {
Categorization,
Category,
@@ -31,12 +30,12 @@ import {
JsonSchema,
Layout,
} from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import CategorizationRenderer, { categorizationTester } from '../../src/complex/categorization';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
-import { JsonFormsStyleContext } from '../../src/styles';
+import { initCore } from '../util';
+import { vanillaRenderers } from '../../src';
Enzyme.configure({ adapter: new Adapter() });
@@ -60,29 +59,7 @@ const fixture = {
type: 'Categorization',
label: 'A',
elements: [category]
- },
- styles: [
- {
- name: 'categorization',
- classNames: ['categorization']
- },
- {
- name: 'categorization.master',
- classNames: ['categorization-master']
- },
- {
- name: 'category.group',
- classNames: ['category-group']
- },
- {
- name: 'category.subcategories',
- classNames: ['category-subcategories']
- },
- {
- name: 'categorization.detail',
- classNames: ['categorization-detail']
- }
- ]
+ }
};
describe('Categorization tester', () => {
@@ -270,23 +247,15 @@ describe('Categorization renderer', () => {
}
]
};
+ const core = initCore(schema, uischema, fixture.data);
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema,
- uischema
- });
wrapper = mount(
-
-
-
-
-
-
-
+
+
+
);
const div = wrapper.find('.categorization').getDOMNode();
@@ -362,23 +331,15 @@ describe('Categorization renderer', () => {
},
]
};
- const store = initJsonFormsVanillaStore({
- data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, data);
wrapper = mount(
-
-
-
-
-
-
-
+
+
+
);
const div: HTMLDivElement = wrapper.find('.categorization').getDOMNode();
@@ -426,24 +387,16 @@ describe('Categorization renderer', () => {
}
]
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
-
-
+
+
+
);
const div = wrapper.find('.categorization').getDOMNode() as HTMLDivElement;
@@ -462,22 +415,15 @@ describe('Categorization renderer', () => {
}
]
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
+
wrapper = mount(
-
-
-
-
-
-
-
+
+
+
);
const div: HTMLDivElement = wrapper.find('.categorization').getDOMNode();
diff --git a/packages/vanilla/test/renderers/DateCell.test.tsx b/packages/vanilla/test/renderers/DateCell.test.tsx
index 6cb393ef93..de84044c63 100644
--- a/packages/vanilla/test/renderers/DateCell.test.tsx
+++ b/packages/vanilla/test/renderers/DateCell.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -25,18 +25,16 @@
import * as React from 'react';
import {
ControlElement,
- getData,
HorizontalLayout,
JsonSchema,
- update
} from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import HorizontalLayoutRenderer from '../../src/layouts/HorizontalLayout';
import DateCell, { dateCellTester } from '../../src/cells/DateCell';
-import { Provider } from 'react-redux';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore, TestEmitter } from '../util';
+import { vanillaRenderers } from '../../src';
Enzyme.configure({ adapter: new Adapter() });
@@ -161,17 +159,11 @@ describe('Date cell', () => {
'firstDate': '1980-04-04',
'secondDate': '1980-04-04'
};
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema
- });
+ const core = initCore(schema, uischema, data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const inputs = wrapper.find('input');
expect(document.activeElement).not.toBe(inputs.at(0));
@@ -186,18 +178,12 @@ describe('Date cell', () => {
focus: true
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode();
expect(document.activeElement).toBe(input);
@@ -211,17 +197,11 @@ describe('Date cell', () => {
focus: false
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
@@ -232,34 +212,22 @@ describe('Date cell', () => {
type: 'Control',
scope: '#/properties/foo'
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
});
test('render', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
@@ -268,17 +236,11 @@ describe('Date cell', () => {
});
test('has classes set', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
expect(input.hasClass('input')).toBe(true);
@@ -287,163 +249,126 @@ describe('Date cell', () => {
});
test('update via event', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const input = wrapper.find('input');
input.simulate('change', { target: { value: '1961-04-12' } });
- expect(getData(store.getState()).foo).toBe('1961-04-12');
+ expect(onChangeData.data.foo).toBe('1961-04-12');
});
test('update via action', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => '1961-04-12'));
+ core.data = { ...core.data, foo: '1961-04-12' };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core }} );
wrapper.update();
const input = wrapper.find('input');
expect(input.props().value).toBe('1961-04-12');
});
test('update with null value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => null));
+ core.data = { ...core.data, foo: null };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core }} );
wrapper.update();
const input = wrapper.find('input');
expect(input.props().value).toBe('');
});
test('update with undefined value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => undefined));
+ core.data = { ...core.data, foo: undefined };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core }} );
wrapper.update();
const input = wrapper.find('input');
expect(input.props().value).toBe('');
});
test('update with wrong ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
- store.dispatch(update('bar', () => 'Bar'));
+ core.data = { ...core.data, bar: 'Bar' };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core }} );
+ wrapper.update();
expect(input.props().value).toBe('1980-04-04');
});
test('update with null ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
- store.dispatch(update(null, () => '1961-04-12'));
+ core.data = { ...core.data, null: '1961-04-12' };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core }} );
+ wrapper.update();
expect(input.props().value).toBe('1980-04-04');
});
test('update with undefined ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
- store.dispatch(update(undefined, () => '1961-04-12'));
+ core.data = { ...core.data, undefined: '1961-04-12' };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core }} );
+ wrapper.update();
expect(input.props().value).toBe('1980-04-04');
});
test('disable', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
expect(input.props().disabled).toBe(true);
});
test('enabled by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
expect(input.props().disabled).toBe(false);
diff --git a/packages/vanilla/test/renderers/DateTimeCell.test.tsx b/packages/vanilla/test/renderers/DateTimeCell.test.tsx
index a9a3a7f6a2..476226d31e 100644
--- a/packages/vanilla/test/renderers/DateTimeCell.test.tsx
+++ b/packages/vanilla/test/renderers/DateTimeCell.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -25,18 +25,15 @@
import * as React from 'react';
import {
ControlElement,
- getData,
HorizontalLayout,
JsonSchema,
- update
} from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
-import { Provider } from 'react-redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import HorizontalLayoutRenderer from '../../src/layouts/HorizontalLayout';
import DateTimeCell, { dateTimeCellTester } from '../../src/cells/DateTimeCell';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore, TestEmitter } from '../util';
Enzyme.configure({ adapter: new Adapter() });
@@ -161,17 +158,11 @@ describe('date time cell', () => {
'firstDate': '1980-04-04T13:37:00.000Z',
'secondDate': '1980-04-04T13:37:00.000Z'
};
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema
- });
+ const core = initCore(schema, uischema, data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const inputs = wrapper.find('input');
expect(document.activeElement).not.toBe(inputs.at(0));
@@ -186,22 +177,16 @@ describe('date time cell', () => {
focus: true
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode();
expect(document.activeElement).toBe(input);
@@ -215,21 +200,16 @@ describe('date time cell', () => {
focus: false
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
+
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
@@ -240,42 +220,31 @@ describe('date time cell', () => {
type: 'Control',
scope: '#/properties/foo'
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
+
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
});
test('render', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
@@ -284,21 +253,15 @@ describe('date time cell', () => {
});
test('has classes set', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
@@ -308,201 +271,163 @@ describe('date time cell', () => {
});
test('update via event', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const input = wrapper.find('input');
input.simulate('change', { target: { value: '1961-04-12T20:15' } });
- expect(getData(store.getState()).foo).toBe('1961-04-12T20:15:00.000Z');
+ expect(onChangeData.data.foo).toBe('1961-04-12T20:15:00.000Z');
});
test('update via action', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => '1961-04-12T20:15:00.000Z'));
+ core.data = { ...core.data, foo: '1961-04-12T20:15:00.000Z' };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
const input = wrapper.find('input');
expect(input.props().value).toBe('1961-04-12T20:15');
});
test('update with null value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => null));
+ core.data = { ...core.data, foo: null };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
const input = wrapper.find('input');
expect(input.props().value).toBe('');
});
test('update with undefined value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => undefined));
+ core.data = { ...core.data, foo: undefined };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
const input = wrapper.find('input');
expect(input.props().value).toBe('');
});
test('update with wrong ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('bar', () => 'Bar'));
+ core.data = { ...core.data, bar: 'Bar' };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
const input = wrapper.find('input');
expect(input.props().value).toBe('1980-04-04T13:37');
});
test('update with null ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
- store.dispatch(update(null, () => '1961-04-12T20:15:00.000Z'));
+ core.data = { ...core.data, null: '1961-04-12T20:15:00.000Z' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(input.props().value).toBe('1980-04-04T13:37');
});
test('update with undefined ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
- store.dispatch(update(undefined, () => '1961-04-12T20:15:00.000Z'));
+ core.data = { ...core.data, undefined: '1961-04-12T20:15:00.000Z' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(input.props().value).toBe('1980-04-04T13:37');
});
test('disable', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
expect(input.props().disabled).toBe(true);
});
test('enabled by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
expect(input.props().disabled).toBe(false);
diff --git a/packages/vanilla/test/renderers/EnumCell.test.tsx b/packages/vanilla/test/renderers/EnumCell.test.tsx
index bfc202efb7..7e88d2ae5c 100644
--- a/packages/vanilla/test/renderers/EnumCell.test.tsx
+++ b/packages/vanilla/test/renderers/EnumCell.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,13 +23,12 @@
THE SOFTWARE.
*/
import * as React from 'react';
-import { ControlElement, getData, update } from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
+import { ControlElement } from '@jsonforms/core';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import EnumCell, { enumCellTester } from '../../src/cells/EnumCell';
-import { Provider } from 'react-redux';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore, TestEmitter } from '../util';
Enzyme.configure({ adapter: new Adapter() });
@@ -135,17 +134,11 @@ describe('Enum cell', () => {
afterEach(() => wrapper.unmount());
test('render', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const select = wrapper.find('select').getDOMNode() as HTMLSelectElement;
@@ -158,17 +151,11 @@ describe('Enum cell', () => {
});
test('has classes set', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('select');
@@ -178,95 +165,80 @@ describe('Enum cell', () => {
});
test('update via input event', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const select = wrapper.find('select');
select.simulate('change', { target: { value: 'b' } });
- expect(getData(store.getState()).foo).toBe('b');
+ expect(onChangeData.data.foo).toBe('b');
});
test('update via action', () => {
const data = { 'foo': 'b' };
- const store = initJsonFormsVanillaStore({
- data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const select = wrapper.find('select').getDOMNode() as HTMLSelectElement;
- store.dispatch(update('foo', () => 'b'));
+ core.data = { ...core.data, foo: 'b' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(select.value).toBe('b');
expect(select.selectedIndex).toBe(2);
});
test('update with undefined value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const select = wrapper.find('select').getDOMNode() as HTMLSelectElement;
- store.dispatch(update('foo', () => undefined));
+ core.data = { ...core.data, foo: undefined };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(select.selectedIndex).toBe(0);
expect(select.value).toBe('');
});
test('update with null value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const select = wrapper.find('select').getDOMNode() as HTMLSelectElement;
- store.dispatch(update('foo', () => null));
+ core.data = { ...core.data, foo: null };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(select.selectedIndex).toBe(0);
expect(select.value).toBe('');
});
test('update with wrong ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('bar', () => 'Bar'));
+ core.data = { ...core.data, bar: 'Bar' };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
const select = wrapper.find('select').getDOMNode() as HTMLSelectElement;
expect(select.selectedIndex).toBe(1);
@@ -274,19 +246,14 @@ describe('Enum cell', () => {
});
test('update with null ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update(null, () => false));
+ core.data = { ...core.data, null: false };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
const select = wrapper.find('select').getDOMNode() as HTMLSelectElement;
expect(select.selectedIndex).toBe(1);
@@ -294,53 +261,37 @@ describe('Enum cell', () => {
});
test('update with undefined ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update(undefined, () => false));
+ core.data = { ...core.data, undefined: false };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const select = wrapper.find('select').getDOMNode() as HTMLSelectElement;
expect(select.selectedIndex).toBe(1);
expect(select.value).toBe('a');
});
test('disable', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const select = wrapper.find('select');
expect(select.props().disabled).toBe(true);
});
test('enabled by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const select = wrapper.find('select');
expect(select.props().disabled).toBe(false);
diff --git a/packages/vanilla/test/renderers/GroupLayout.test.tsx b/packages/vanilla/test/renderers/GroupLayout.test.tsx
index b3112fd5cc..a03986c9a4 100644
--- a/packages/vanilla/test/renderers/GroupLayout.test.tsx
+++ b/packages/vanilla/test/renderers/GroupLayout.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -24,12 +24,11 @@
*/
import * as React from 'react';
import { GroupLayout } from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
-import { Provider } from 'react-redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import GroupLayoutRenderer, { groupTester } from '../../src/layouts/GroupLayout';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore } from '../util';
Enzyme.configure({ adapter: new Adapter() });
@@ -59,17 +58,11 @@ describe('Group layout', () => {
label: 'Foo',
elements: [],
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema
- });
+ const core = initCore({}, uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const groupLayout = wrapper.find('.group-layout').getDOMNode();
const legend = groupLayout.children[0];
@@ -86,17 +79,11 @@ describe('Group layout', () => {
type: 'Group',
elements: null
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema
- });
+ const core = initCore({}, uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const groupLayout = wrapper.find('.group-layout').getDOMNode();
expect(groupLayout.tagName).toBe('FIELDSET');
@@ -111,17 +98,11 @@ describe('Group layout', () => {
{ type: 'Control' }
]
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema
- });
+ const core = initCore({}, uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const groupLayout = wrapper.find('.group-layout').getDOMNode();
expect(groupLayout.tagName).toBe('FIELDSET');
@@ -129,37 +110,25 @@ describe('Group layout', () => {
});
test('hide', () => {
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema: fixture.uischema
- });
+ const core = initCore({}, fixture.uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const groupLayout = wrapper.find('.group-layout');
expect(groupLayout.props().hidden).toBe(true);
});
test('show by default', () => {
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema: fixture.uischema
- });
+ const core = initCore({}, fixture.uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const groupLayout = wrapper.find('.group-layout');
expect(groupLayout.props().hidden).toBe(false);
diff --git a/packages/vanilla/test/renderers/HorizontalLayout.test.tsx b/packages/vanilla/test/renderers/HorizontalLayout.test.tsx
index accbc656f2..063d806bf3 100644
--- a/packages/vanilla/test/renderers/HorizontalLayout.test.tsx
+++ b/packages/vanilla/test/renderers/HorizontalLayout.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -27,14 +27,13 @@ import {
HorizontalLayout,
UISchemaElement
} from '@jsonforms/core';
-import { Provider } from 'react-redux';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import HorizontalLayoutRenderer, {
horizontalLayoutTester
} from '../../src/layouts/HorizontalLayout';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
+import { initCore } from '../util';
+import { JsonFormsStateProvider } from '@jsonforms/react';
Enzyme.configure({ adapter: new Adapter() });
@@ -62,17 +61,11 @@ describe('Horizontal layout', () => {
const uischema: UISchemaElement = {
type: 'HorizontalLayout'
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema
- });
+ const core = initCore({}, uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const horizontalLayout = wrapper.find(HorizontalLayoutRenderer).getDOMNode() as HTMLDivElement;
@@ -86,17 +79,11 @@ describe('Horizontal layout', () => {
type: 'HorizontalLayout',
elements: null
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema
- });
+ const core = initCore({}, uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const horizontalLayout = wrapper.find(HorizontalLayoutRenderer).getDOMNode() as HTMLDivElement;
expect(horizontalLayout).toBeDefined();
@@ -111,17 +98,11 @@ describe('Horizontal layout', () => {
{ type: 'Control' }
]
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema
- });
+ const core = initCore({}, uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const horizontalLayout = wrapper.find(HorizontalLayoutRenderer).getDOMNode() as HTMLDivElement;
expect(horizontalLayout).toBeDefined();
@@ -129,37 +110,25 @@ describe('Horizontal layout', () => {
});
test('hide', () => {
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema: fixture.uischema
- });
+ const core = initCore({}, fixture.uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const horizontalLayout = wrapper.find(HorizontalLayoutRenderer).getDOMNode() as HTMLDivElement;
expect(horizontalLayout.hidden).toBe(true);
});
test('show by default', () => {
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema: fixture.uischema
- });
+ const core = initCore({}, fixture.uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const horizontalLayout = wrapper.find(HorizontalLayoutRenderer).getDOMNode() as HTMLDivElement;
expect(horizontalLayout.hidden).toBe(false);
diff --git a/packages/vanilla/test/renderers/InputControl.test.tsx b/packages/vanilla/test/renderers/InputControl.test.tsx
index 5a8766be56..7db1fa57ff 100644
--- a/packages/vanilla/test/renderers/InputControl.test.tsx
+++ b/packages/vanilla/test/renderers/InputControl.test.tsx
@@ -24,14 +24,13 @@
*/
import * as React from 'react';
import {
- Actions,
ControlElement,
HorizontalLayout,
JsonSchema
} from '@jsonforms/core';
import { JsonFormsDispatch } from '@jsonforms/react';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
-import { Provider } from 'react-redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
+import { vanillaRenderers } from '../../src';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import '../../src';
@@ -44,7 +43,7 @@ import InputControl, {
import BooleanCell, { booleanCellTester } from '../../src/cells/BooleanCell';
import TextCell, { textCellTester } from '../../src/cells/TextCell';
import DateCell, { dateCellTester } from '../../src/cells/DateCell';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore } from '../util';
import { JsonFormsStyleContext } from '../../src/styles';
Enzyme.configure({ adapter: new Adapter() });
@@ -113,22 +112,16 @@ describe('Input control', () => {
firstBooleanCell: true,
secondBooleanCell: false
};
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema,
- renderers: [
- { tester: inputControlTester, renderer: InputControl },
- { tester: horizontalLayoutTester, renderer: HorizontalLayoutRenderer }
- ],
- cells: [{ tester: booleanCellTester, cell: BooleanCell }]
- });
+ const core = initCore(schema, uischema, data);
+ const renderes = [
+ { tester: inputControlTester, renderer: InputControl },
+ { tester: horizontalLayoutTester, renderer: HorizontalLayoutRenderer }
+ ];
+ const cells = [{ tester: booleanCellTester, cell: BooleanCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const inputs = wrapper.find('input');
expect(document.activeElement).not.toBe(inputs.at(0).getDOMNode());
@@ -136,19 +129,13 @@ describe('Input control', () => {
});
test('render', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: booleanCellTester, cell: BooleanCell }]
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: booleanCellTester, cell: BooleanCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const control = wrapper.find('.control').getDOMNode();
@@ -174,19 +161,13 @@ describe('Input control', () => {
scope: '#/properties/foo',
label: false
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: booleanCellTester, cell: BooleanCell }]
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: booleanCellTester, cell: BooleanCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const control = wrapper.find('.control');
@@ -207,116 +188,85 @@ describe('Input control', () => {
});
test('hide', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: booleanCellTester, cell: BooleanCell }]
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: booleanCellTester, cell: BooleanCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const control = wrapper.find('.control').getDOMNode() as HTMLElement;
expect(control.hidden).toBe(true);
});
test('show by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: booleanCellTester, cell: BooleanCell }]
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: booleanCellTester, cell: BooleanCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const control = wrapper.find('.control').getDOMNode() as HTMLElement;
expect(control.hidden);
});
test('single error', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: booleanCellTester, cell: BooleanCell }]
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: booleanCellTester, cell: BooleanCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const validation = wrapper.find('.validation');
- store.dispatch(Actions.update('foo', () => 2));
+ core.data = { ...core.data, foo: 2 };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core, cells, renderes }} );
+ wrapper.update();
expect(validation.text()).toBe('should be boolean');
});
test('multiple errors', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: booleanCellTester, cell: BooleanCell }]
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: booleanCellTester, cell: BooleanCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(Actions.update('foo', () => 3));
+ core.data = { ...core.data, foo: 3 };
+ wrapper.setProps({ initState: { renderers: vanillaRenderers, core, cells, renderes }} );
wrapper.update();
const validation = wrapper.find('.validation');
expect(validation.text()).toBe('should be boolean');
});
test('empty errors by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: booleanCellTester, cell: BooleanCell }]
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: booleanCellTester, cell: BooleanCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const validation = wrapper.find('.validation');
expect(validation.text()).toBe('');
});
test('custom validation class', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: booleanCellTester, cell: BooleanCell }]
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: booleanCellTester, cell: BooleanCell }];
const styleContextValue = { styles: [
{
name: 'control.validation',
@@ -324,36 +274,30 @@ describe('Input control', () => {
},
]};
wrapper = mount(
-
-
-
-
-
-
-
+
+
+
+
+
);
const validation = wrapper.find('.custom-validation');
expect(validation.exists()).toBeTruthy();
});
test('reset validation message', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: booleanCellTester, cell: BooleanCell }]
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: booleanCellTester, cell: BooleanCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const validation = wrapper.find('.validation');
- store.dispatch(Actions.update('foo', () => 3));
- store.dispatch(Actions.update('foo', () => true));
+ core.data = { ...core.data, foo: 3 };
+ core.data = { ...core.data, foo: true };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(validation.text()).toBe('');
});
@@ -399,19 +343,13 @@ describe('Input control', () => {
name: 'John Doe',
personalData: {}
};
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: textCellTester, cell: TextCell }]
- });
+ const core = initCore(schema, uischema, data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: textCellTester, cell: TextCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const validation = wrapper.find('.validation');
expect(validation.at(0).text()).toBe('');
@@ -433,19 +371,13 @@ describe('Input control', () => {
type: 'Control',
scope: '#/properties/dateCell'
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema,
- uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: dateCellTester, cell: DateCell }]
- });
+ const core = initCore(schema, uischema, {});
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: dateCellTester, cell: DateCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const label = wrapper.find('label');
expect(label.text()).toBe('Date Cell*');
@@ -465,19 +397,13 @@ describe('Input control', () => {
type: 'Control',
scope: '#/properties/dateCell'
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema,
- uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: dateCellTester, cell: DateCell }]
- });
+ const core = initCore(schema, uischema, {});
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: dateCellTester, cell: DateCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const label = wrapper.find('label');
expect(label.text()).toBe('Date Cell');
@@ -498,19 +424,13 @@ describe('Input control', () => {
scope: '#/properties/name'
};
const data = { isFocused: false };
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: textCellTester, cell: TextCell }]
- });
+ const core = initCore(schema, uischema, data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: textCellTester, cell: DateCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const control = wrapper.find('.control');
control.simulate('focus');
@@ -533,19 +453,13 @@ describe('Input control', () => {
scope: '#/properties/name'
};
const data = { isFocused: false };
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: textCellTester, cell: TextCell }]
- });
+ const core = initCore(schema, uischema, data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: textCellTester, cell: DateCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const description = wrapper.find('.input-description');
expect(description.text()).toBe('');
@@ -566,19 +480,13 @@ describe('Input control', () => {
scope: '#/properties/name'
};
const data = { isFocused: false };
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: textCellTester, cell: TextCell }]
- });
+ const core = initCore(schema, uischema, data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: textCellTester, cell: DateCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const control = wrapper.find('.control');
control.simulate('focus');
@@ -603,19 +511,13 @@ describe('Input control', () => {
scope: '#/properties/name'
};
const data = { isFocused: false };
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: textCellTester, cell: TextCell }]
- });
+ const core = initCore(schema, uischema, data);
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: textCellTester, cell: DateCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const description = wrapper.find('.input-description').getDOMNode();
expect(description.textContent).toBe('');
@@ -634,19 +536,13 @@ describe('Input control', () => {
type: 'Control',
scope: '#/properties/expectedValue'
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema,
- uischema,
- renderers: [{ tester: inputControlTester, renderer: InputControl }],
- cells: [{ tester: textCellTester, cell: TextCell }]
- });
+ const core = initCore(schema, uischema, {});
+ const renderes = [{ tester: inputControlTester, renderer: InputControl }];
+ const cells = [{ tester: textCellTester, cell: DateCell }];
wrapper = mount(
-
-
-
-
-
+
+
+
);
const control = wrapper.find('.control');
expect(control).toHaveLength(1);
diff --git a/packages/vanilla/test/renderers/IntegerCell.test.tsx b/packages/vanilla/test/renderers/IntegerCell.test.tsx
index fbaff31787..bba37b84dc 100644
--- a/packages/vanilla/test/renderers/IntegerCell.test.tsx
+++ b/packages/vanilla/test/renderers/IntegerCell.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -25,18 +25,15 @@
import * as React from 'react';
import {
ControlElement,
- getData,
HorizontalLayout,
JsonSchema,
- update
} from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
-import { Provider } from 'react-redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import IntegerCell, { integerCellTester } from '../../src/cells/IntegerCell';
import HorizontalLayoutRenderer from '../../src/layouts/HorizontalLayout';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore, TestEmitter } from '../util';
Enzyme.configure({ adapter: new Adapter() });
@@ -135,15 +132,11 @@ describe('Integer cell', () => {
'firstIntegerCell': 10,
'secondIntegerCell': 12
};
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema
- });
+ const core = initCore(schema, uischema, data);
wrapper = mount(
-
+
-
+
);
const inputs = wrapper.find('input');
expect(document.activeElement).not.toBe(inputs.at(0));
@@ -158,15 +151,11 @@ describe('Integer cell', () => {
focus: true
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
+
-
+
);
const input = wrapper.find('input').getDOMNode();
expect(document.activeElement).toBe(input);
@@ -180,16 +169,12 @@ describe('Integer cell', () => {
focus: false
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
+
-
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
@@ -200,33 +185,23 @@ describe('Integer cell', () => {
type: 'Control',
scope: '#/properties/foo'
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
+
-
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
});
test('render', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
@@ -236,17 +211,11 @@ describe('Integer cell', () => {
});
test('has classes set', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
@@ -256,168 +225,128 @@ describe('Integer cell', () => {
});
test('update via input event', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const input = wrapper.find('input');
input.simulate('change', { target: { value: '13' } });
- expect(getData(store.getState()).foo).toBe(13);
+ expect(onChangeData.data.foo).toBe(13);
});
test('update via action', () => {
const data = { 'foo': 13 };
- const store = initJsonFormsVanillaStore({
- data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => 42));
+ core.data = { ...core.data, foo: 42 };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('42');
});
test('update with undefined value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => undefined));
+ core.data = { ...core.data, foo: undefined };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('');
});
test('update with null value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => null));
+ core.data = { ...core.data, foo: null };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('');
});
test('update with wrong ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('bar', () => 11));
+ core.data = { ...core.data, bar: 11 };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('42');
});
test('update with null ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update(null, () => 13));
+ core.data = { ...core.data, null: 13 };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('42');
});
test('update with undefined ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update(undefined, () => 13));
+ core.data = { ...core.data, undefined: 13 };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('42');
});
test('disable', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.disabled).toBe(true);
});
test('enabled by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.disabled).toBe(false);
diff --git a/packages/vanilla/test/renderers/LabelControl.test.tsx b/packages/vanilla/test/renderers/LabelControl.test.tsx
index 4f9a97810a..f485f93676 100644
--- a/packages/vanilla/test/renderers/LabelControl.test.tsx
+++ b/packages/vanilla/test/renderers/LabelControl.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -24,14 +24,13 @@
*/
import * as React from 'react';
import { LabelElement, UISchemaElement } from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
-import { Provider } from 'react-redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import LabelRenderer, {
labelRendererTester
} from '../../src/complex/LabelRenderer';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore } from '../util';
import { JsonFormsStyleContext } from '../../src/styles';
Enzyme.configure({ adapter: new Adapter() });
@@ -68,22 +67,16 @@ describe('Label', () => {
test('render with undefined text', () => {
const uischema: UISchemaElement = { type: 'Label' };
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
-
-
+
+
+
+
+
);
const label = wrapper.find('label').getDOMNode();
@@ -96,23 +89,17 @@ describe('Label', () => {
type: 'Label',
text: null
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
-
-
+
+
+
+
+
);
const label = wrapper.find('label').getDOMNode();
expect(label.className).toBe('jsf-label');
@@ -120,22 +107,16 @@ describe('Label', () => {
});
test('render with text', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
-
-
+
+
+
+
+
);
const label = wrapper.find('label').getDOMNode();
expect(label.className).toBe('jsf-label');
@@ -144,41 +125,29 @@ describe('Label', () => {
});
test('hide', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const label = wrapper.find('label').getDOMNode() as HTMLLabelElement;
expect(label.hidden).toBe(true);
});
test('show by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const label = wrapper.find('label').getDOMNode() as HTMLLabelElement;
expect(label.hidden).toBe(false);
diff --git a/packages/vanilla/test/renderers/NumberCell.test.tsx b/packages/vanilla/test/renderers/NumberCell.test.tsx
index faefa8628a..f614ccd64f 100644
--- a/packages/vanilla/test/renderers/NumberCell.test.tsx
+++ b/packages/vanilla/test/renderers/NumberCell.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -25,18 +25,15 @@
import * as React from 'react';
import {
ControlElement,
- getData,
HorizontalLayout,
JsonSchema,
- update
} from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
-import { Provider } from 'react-redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import NumberCell, { numberCellTester } from '../../src/cells/NumberCell';
import HorizontalLayoutRenderer from '../../src/layouts/HorizontalLayout';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore, TestEmitter } from '../util';
Enzyme.configure({ adapter: new Adapter() });
@@ -175,17 +172,11 @@ describe('Number cell', () => {
'firstNumberCell': 3.14,
'secondNumberCell': 5.12
};
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema
- });
+ const core = initCore(schema, uischema, data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const inputs = wrapper.find('input');
@@ -201,17 +192,11 @@ describe('Number cell', () => {
focus: true
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(document.activeElement).toBe(input);
@@ -225,18 +210,12 @@ describe('Number cell', () => {
focus: false
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
@@ -247,17 +226,11 @@ describe('Number cell', () => {
type: 'Control',
scope: '#/properties/foo'
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
@@ -265,17 +238,11 @@ describe('Number cell', () => {
test('render', () => {
const schema: JsonSchema = { type: 'number' };
- const store = initJsonFormsVanillaStore({
- data: { 'foo': 3.14 },
- schema,
- uischema: fixture.uischema
- });
+ const core = initCore(schema, fixture.uischema, { 'foo': 3.14 });
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
@@ -285,17 +252,11 @@ describe('Number cell', () => {
});
test('has classes set', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
@@ -305,180 +266,139 @@ describe('Number cell', () => {
});
test('update via input event', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const input = wrapper.find('input');
input.simulate('change', { target: { value: '2.72' } });
wrapper.update();
- expect(getData(store.getState()).foo).toBe(2.72);
+ expect(onChangeData.data.foo).toBe(2.72);
});
test('update via action', () => {
- const store = initJsonFormsVanillaStore({
- data: { foo: 2.72 },
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, { foo: 2.72 });
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('2.72');
- store.dispatch(update('foo', () => 3.14));
+ core.data = { ...core.data, foo: 3.14 };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
expect(input.value).toBe('3.14');
});
test('update with undefined value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
- store.dispatch(update('foo', () => undefined));
+ core.data = { ...core.data, foo: undefined };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(input.value).toBe('');
});
test('update with null value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
- store.dispatch(update('foo', () => null));
+ core.data = { ...core.data, foo: null };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(input.value).toBe('');
});
test('update with wrong ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
- store.dispatch(update('bar', () => 11));
+ core.data = { ...core.data, bar: 11 };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(input.value).toBe('3.14');
});
test('update with null ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
- store.dispatch(update(null, () => 2.72));
+ core.data = { ...core.data, null: 2.72 };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(input.value).toBe('3.14');
});
test('update with undefined ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update(undefined, () => 13));
+ core.data = { ...core.data, undefined: 13 };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('3.14');
});
test('disable', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.disabled).toBe(true);
});
test('enabled by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.disabled).toBe(false);
});
test('shows 0 instead of empty string', () => {
- const store = initJsonFormsVanillaStore({
- data: { foo: 0 },
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, { foo: 0 });
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('0');
diff --git a/packages/vanilla/test/renderers/RadioGroupControl.test.tsx b/packages/vanilla/test/renderers/RadioGroupControl.test.tsx
index ed312f2975..264520a68a 100644
--- a/packages/vanilla/test/renderers/RadioGroupControl.test.tsx
+++ b/packages/vanilla/test/renderers/RadioGroupControl.test.tsx
@@ -23,89 +23,76 @@
THE SOFTWARE.
*/
import {
- isEnumControl,
- rankWith,
- update
+ isEnumControl,
+ rankWith,
} from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import * as React from 'react';
import * as _ from 'lodash';
-import { Provider } from 'react-redux';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import '../../src';
import RadioGroupControl from '../../src/controls/RadioGroupControl';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore } from '../util';
Enzyme.configure({ adapter: new Adapter() });
const fixture = {
- data: { foo: 'D' },
- schema: {
- type: 'object',
- properties: {
- foo: {
- type: 'string',
- enum: ['A', 'B', 'C', 'D']
- }
- }
- },
- uischema: {
- type: 'Control',
- scope: '#/properties/foo'
+ data: { foo: 'D' },
+ schema: {
+ type: 'object',
+ properties: {
+ foo: {
+ type: 'string',
+ enum: ['A', 'B', 'C', 'D']
+ }
}
+ },
+ uischema: {
+ type: 'Control',
+ scope: '#/properties/foo'
+ }
};
describe('Radio group control', () => {
- let wrapper: ReactWrapper;
+ let wrapper: ReactWrapper;
- afterEach(() => wrapper.unmount());
+ afterEach(() => wrapper.unmount());
- test('render', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema,
- renderers: [{ tester: rankWith(10, isEnumControl), renderer: RadioGroupControl }]
- });
- wrapper = mount(
-
-
-
-
-
- );
+ test('render', () => {
+ const renderers = [{ tester: rankWith(10, isEnumControl), renderer: RadioGroupControl }];
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
+ wrapper = mount(
+
+
+
+ );
- const radioButtons = wrapper.find('input[type="radio"]');
- expect(radioButtons).toHaveLength(4);
- // make sure one option is selected and iexpect "D"
- const currentlyChecked = radioButtons.filter('input[checked=true]');
- expect(currentlyChecked).toHaveLength(1);
- expect((currentlyChecked.getDOMNode() as HTMLInputElement).value).toBe('D');
- });
+ const radioButtons = wrapper.find('input[type="radio"]');
+ expect(radioButtons).toHaveLength(4);
+ // make sure one option is selected and iexpect "D"
+ const currentlyChecked = radioButtons.filter('input[checked=true]');
+ expect(currentlyChecked).toHaveLength(1);
+ expect((currentlyChecked.getDOMNode() as HTMLInputElement).value).toBe('D');
+ });
- test('Radio group should have only one selected option', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema,
- renderers: [{ tester: rankWith(10, isEnumControl), renderer: RadioGroupControl }]
- });
- wrapper = mount(
-
-
-
-
-
- );
+ test('Radio group should have only one selected option', () => {
+ const renderers = [{ tester: rankWith(10, isEnumControl), renderer: RadioGroupControl }];
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
+ wrapper = mount(
+
+
+
+ );
- // change and verify selection
- store.dispatch(update('foo', () => 'A'));
- store.dispatch(update('foo', () => 'B'));
- wrapper.update();
- const currentlyChecked = wrapper.find('input[checked=true]');
- expect(currentlyChecked).toHaveLength(1);
- expect((currentlyChecked.getDOMNode() as HTMLInputElement).value).toBe('B');
- });
+ // change and verify selection
+ core.data = { ...core.data, foo: 'A' };
+ core.data = { ...core.data, foo: 'B' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
+ const currentlyChecked = wrapper.find('input[checked=true]');
+ expect(currentlyChecked).toHaveLength(1);
+ expect((currentlyChecked.getDOMNode() as HTMLInputElement).value).toBe('B');
+ });
});
diff --git a/packages/vanilla/test/renderers/SliderCell.test.tsx b/packages/vanilla/test/renderers/SliderCell.test.tsx
index 29d2d41f6c..2d1ee7b00f 100644
--- a/packages/vanilla/test/renderers/SliderCell.test.tsx
+++ b/packages/vanilla/test/renderers/SliderCell.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -25,18 +25,15 @@
import * as React from 'react';
import {
ControlElement,
- getData,
HorizontalLayout,
JsonSchema,
- update
} from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
-import { Provider } from 'react-redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import SliderCell, { sliderCellTester } from '../../src/cells/SliderCell';
import HorizontalLayoutRenderer from '../../src/layouts/HorizontalLayout';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore, TestEmitter } from '../util';
Enzyme.configure({ adapter: new Adapter() });
@@ -274,17 +271,11 @@ describe('Slider cell', () => {
firstSliderCell: 3.14,
secondSliderCell: 5.12
};
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema
- });
+ const core = initCore(schema, uischema, data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const inputs = wrapper.find('input');
@@ -298,21 +289,15 @@ describe('Slider cell', () => {
scope: '#/properties/foo',
options: { focus: true }
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
expect(document.activeElement).toBe(input.getDOMNode());
@@ -324,42 +309,30 @@ describe('Slider cell', () => {
scope: '#/properties/foo',
options: { focus: false }
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
});
test('autofocus inactive by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
@@ -377,21 +350,15 @@ describe('Slider cell', () => {
}
}
};
- const store = initJsonFormsVanillaStore({
- data: { 'foo': 5 },
- schema,
- uischema: fixture.uischema
- });
+ const core = initCore(schema, fixture.uischema, { 'foo': 5 });
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.type).toBe('range');
@@ -399,21 +366,15 @@ describe('Slider cell', () => {
});
test('has classes set', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
@@ -423,198 +384,164 @@ describe('Slider cell', () => {
});
test('update via input event', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const input = wrapper.find('input');
input.simulate('change', { target: { value: 3 } });
wrapper.update();
- expect(getData(store.getState()).foo).toBe(3);
+ expect(onChangeData.data.foo).toBe(3);
});
test('update via action', () => {
- const store = initJsonFormsVanillaStore({
- data: { 'foo': 3 },
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, { 'foo': 3 });
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => 4));
+ core.data = { ...core.data, foo: 4 };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('4');
});
// FIXME expect moves the slider and changes the value
test.skip('update with undefined value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => undefined));
+ core.data = { ...core.data, foo: undefined };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('');
});
// FIXME expect moves the slider and changes the value
test.skip('update with null value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => null));
+ core.data = { ...core.data, foo: null };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('');
});
test('update with wrong ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('bar', () => 11));
+ core.data = { ...core.data, bar: 11 };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('5');
});
test('update with null ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
- store.dispatch(update(null, () => 3));
+ core.data = { ...core.data, null: 3 };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(input.value).toBe('5');
});
test('update with undefined ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update(undefined, () => 13));
+ core.data = { ...core.data, undefined: 13 };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('5');
});
test('disable', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.disabled).toBe(true);
});
test('enabled by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.disabled).toBe(false);
diff --git a/packages/vanilla/test/renderers/TableArrayControl.test.tsx b/packages/vanilla/test/renderers/TableArrayControl.test.tsx
index 29c9faa31e..6024718f69 100644
--- a/packages/vanilla/test/renderers/TableArrayControl.test.tsx
+++ b/packages/vanilla/test/renderers/TableArrayControl.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -24,20 +24,17 @@
*/
import * as React from 'react';
import * as _ from 'lodash';
-import { Provider } from 'react-redux';
import {
ControlElement,
- getData,
HorizontalLayout,
- update
} from '@jsonforms/core';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import TableArrayControl, { tableArrayControlTester, } from '../../src/complex/TableArrayControl';
import HorizontalLayoutRenderer from '../../src/layouts/HorizontalLayout';
import '../../src';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore, TestEmitter } from '../util';
import IntegerCell, { integerCellTester } from '../../src/cells/IntegerCell';
Enzyme.configure({ adapter: new Adapter() });
@@ -204,23 +201,15 @@ describe('Tabe array control', () => {
afterEach(() => wrapper.unmount());
test('render two children', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema,
- cells: [
- { tester: integerCellTester, cell: IntegerCell }
- ]
- });
+ const cells = [{ tester: integerCellTester, cell: IntegerCell }];
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const header = wrapper.find('header').getDOMNode();
@@ -275,20 +264,14 @@ describe('Tabe array control', () => {
type: 'Control',
scope: '#/properties/test'
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: fixture.schema,
- uischema: control
- });
+ const core = initCore(fixture.schema, control, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const header = wrapper.find('header').getDOMNode();
@@ -334,23 +317,15 @@ describe('Tabe array control', () => {
});
test('use property title as a column header if it exists', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture2.data,
- schema: fixture2.schema,
- uischema: fixture2.uischema,
- cells: [
- { tester: integerCellTester, cell: IntegerCell }
- ]
- });
+ const cells = [{ tester: integerCellTester, cell: IntegerCell }];
+ const core = initCore(fixture2.schema, fixture2.uischema, fixture2.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
//column headings are wrapped in a tag
@@ -364,20 +339,22 @@ describe('Tabe array control', () => {
});
test('render new child (empty init data)', () => {
- const store = initJsonFormsVanillaStore({
- data: { test: [] },
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, { test: [] });
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const control = wrapper.find('.root_properties_test');
@@ -385,24 +362,26 @@ describe('Tabe array control', () => {
const button = wrapper.find('button');
button.simulate('click');
- expect(getData(store.getState()).test).toHaveLength(1);
+ expect(onChangeData.data.test).toHaveLength(1);
});
test('render new child (undefined data)', () => {
- const store = initJsonFormsVanillaStore({
- data: { test: undefined },
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, { test: undefined });
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const control = wrapper.find('.root_properties_test');
@@ -410,24 +389,26 @@ describe('Tabe array control', () => {
const button = wrapper.find('button');
button.simulate('click');
- expect(getData(store.getState()).test).toHaveLength(1);
+ expect(onChangeData.data.test).toHaveLength(1);
});
test('render new child (null data)', () => {
- const store = initJsonFormsVanillaStore({
- data: { test: null },
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, { test: null });
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const control = wrapper.find('.root_properties_test');
@@ -435,29 +416,31 @@ describe('Tabe array control', () => {
const button = wrapper.find('button');
button.simulate('click');
- expect(getData(store.getState()).test).toHaveLength(1);
+ expect(onChangeData.data.test).toHaveLength(1);
});
test('render new child', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const addButton = wrapper.find('button').first();
addButton.simulate('click');
- expect(getData(store.getState()).test).toHaveLength(2);
+ expect(onChangeData.data.test).toHaveLength(2);
});
test('render primitives ', () => {
@@ -477,20 +460,14 @@ describe('Tabe array control', () => {
type: 'Control',
scope: '#/properties/test'
};
- const store = initJsonFormsVanillaStore({
- data: { test: ['foo', 'bars'] },
- schema,
- uischema
- });
+ const core = initCore(schema, uischema, { test: ['foo', 'bars'] });
wrapper = mount(
-
-
-
-
-
+
+
+
);
const rows = wrapper.find('tr');
const lastRow = rows.last().getDOMNode() as HTMLTableRowElement;
@@ -499,156 +476,124 @@ describe('Tabe array control', () => {
});
test('update via action', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const children = wrapper.find('tbody').getDOMNode();
expect(children.childNodes).toHaveLength(1);
- store.dispatch(update('test', () => [{ x: 1, y: 3 }, { x: 2, y: 3 }]));
+ core.data = { ...core.data, test: [{ x: 1, y: 3 }, { x: 2, y: 3 }] };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(children.childNodes).toHaveLength(2);
- store.dispatch(update(undefined, () => [{ x: 1, y: 3 }, { x: 2, y: 3 }, { x: 3, y: 3 }]));
+ core.data = { ...core.data, undefined: [{ x: 1, y: 3 }, { x: 2, y: 3 }, { x: 3, y: 3 }] };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(children.childNodes).toHaveLength(2);
});
test('hide', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const control = wrapper.find('.control').getDOMNode() as HTMLElement;
expect(control.hidden).toBe(true);
});
test('show by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const control = wrapper.find('.control').getDOMNode() as HTMLElement;
expect(control.hidden).toBe(false);
});
test('single error', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('test', () => 2));
+ core.data = { ...core.data, test: 2 };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const validation = wrapper.find('.validation').getDOMNode();
expect(validation.textContent).toBe('should be array');
});
test('multiple errors', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('test', () => 3));
+ core.data = { ...core.data, test: 3 };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const validation = wrapper.find('.validation').getDOMNode();
expect(validation.textContent).toBe('should be array');
});
test('empty errors by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const validation = wrapper.find('.validation').getDOMNode();
expect(validation.textContent).toBe('');
});
test('reset validation message', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const validation = wrapper.find('.validation').getDOMNode();
- store.dispatch(update('test', () => 3));
+ core.data = { ...core.data, test: 3 };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
expect(validation.textContent).toBe('should be array');
- store.dispatch(update('test', () => []));
+ core.data = { ...core.data, test: [] };
+ wrapper.setProps({ initState: { core }} );
wrapper.update();
expect(validation.textContent).toBe('');
});
@@ -685,18 +630,11 @@ describe('Tabe array control', () => {
type: 'HorizontalLayout',
elements: [firstControl, secondControl, thirdControl]
};
- const store = initJsonFormsVanillaStore({
- data: {
- name: 'John Doe',
- personalData: {}
- },
- schema,
- uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, {name: 'John Doe', personalData: {} });
wrapper = mount(
-
+
-
+
);
const validation = wrapper.find('.valdiation');
expect(validation.at(0).getDOMNode().textContent).toBe('');
diff --git a/packages/vanilla/test/renderers/TextAreaCell.test.tsx b/packages/vanilla/test/renderers/TextAreaCell.test.tsx
index b689cd4375..13d66e7b95 100644
--- a/packages/vanilla/test/renderers/TextAreaCell.test.tsx
+++ b/packages/vanilla/test/renderers/TextAreaCell.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -25,18 +25,15 @@
import * as React from 'react';
import {
ControlElement,
- getData,
HorizontalLayout,
JsonSchema,
- update
} from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
-import { Provider } from 'react-redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import TextAreaCell, { textAreaCellTester, } from '../../src/cells/TextAreaCell';
import HorizontalLayoutRenderer from '../../src/layouts/HorizontalLayout';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore, TestEmitter } from '../util';
Enzyme.configure({ adapter: new Adapter() });
@@ -103,15 +100,11 @@ describe('Text area cell', () => {
'firstName': 'Foo',
'lastName': 'Boo'
};
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema
- });
+ const core = initCore(schema, uischema, data);
wrapper = mount(
-
+
-
+
);
const inputs = wrapper.find('input');
expect(document.activeElement).not.toBe(inputs.at(0).getDOMNode());
@@ -126,15 +119,11 @@ describe('Text area cell', () => {
focus: true
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
+
-
+
);
const input = wrapper.find('textarea').getDOMNode();
expect(document.activeElement).toBe(input);
@@ -148,15 +137,11 @@ describe('Text area cell', () => {
focus: false
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
+
-
+
);
const input = wrapper.find('textarea').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
@@ -167,49 +152,33 @@ describe('Text area cell', () => {
type: 'Control',
scope: '#/properties/name'
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
+
-
+
);
const input = wrapper.find('textarea').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
});
test('render', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const textarea = wrapper.find('textarea').getDOMNode() as HTMLTextAreaElement;
expect(textarea.value).toBe('Foo');
});
test('has classes set', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('textarea');
@@ -219,161 +188,127 @@ describe('Text area cell', () => {
});
test('update via input event', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const textarea = wrapper.find('textarea');
textarea.simulate('change', { target: { value: 'Bar' } });
- expect(getData(store.getState()).name).toBe('Bar');
+ expect(onChangeData.data.name).toBe('Bar');
});
test('update via action', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('name', () => 'Bar'));
+ core.data = { ...core.data, name: 'Bar' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const textarea = wrapper.find('textarea').getDOMNode() as HTMLTextAreaElement;
expect(textarea.value).toBe('Bar');
});
test('update with undefined value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const textArea = wrapper.find('textarea').getDOMNode() as HTMLTextAreaElement;
- store.dispatch(update('name', () => undefined));
+ core.data = { ...core.data, name: undefined };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(textArea.value).toBe('');
});
test('update with null value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('name', () => null));
+ core.data = { ...core.data, name: null };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const textArea = wrapper.find('textarea').getDOMNode() as HTMLTextAreaElement;
expect(textArea.value).toBe('');
});
test('update with wrong ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('firstname', () => 'Bar'));
+ core.data = { ...core.data, firstname: 'Bar' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const textArea = wrapper.find('textarea').getDOMNode() as HTMLTextAreaElement;
expect(textArea.value).toBe('Foo');
});
test('update with null ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update(null, () => 'Bar'));
+ core.data = { ...core.data, null: 'Bar' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const textArea = wrapper.find('textarea').getDOMNode() as HTMLTextAreaElement;
expect(textArea.value).toBe('Foo');
});
test('update with undefined ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const textArea = wrapper.find('textarea').getDOMNode() as HTMLTextAreaElement;
- store.dispatch(update(undefined, () => 'Bar'));
+ core.data = { ...core.data, undefined: 'Bar' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(textArea.value).toBe('Foo');
});
test('disable', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const textArea = wrapper.find('textarea').getDOMNode() as HTMLTextAreaElement;
expect(textArea.disabled).toBe(true);
});
test('enabled by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const textArea = wrapper.find('textarea').getDOMNode() as HTMLTextAreaElement;
expect(textArea.disabled).toBe(false);
diff --git a/packages/vanilla/test/renderers/TextCell.test.tsx b/packages/vanilla/test/renderers/TextCell.test.tsx
index b77226a227..b9c4f14339 100644
--- a/packages/vanilla/test/renderers/TextCell.test.tsx
+++ b/packages/vanilla/test/renderers/TextCell.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -25,18 +25,15 @@
import * as React from 'react';
import {
ControlElement,
- getData,
HorizontalLayout,
JsonSchema,
- update
} from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
-import { Provider } from 'react-redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import TextCell, { textCellTester } from '../../src/cells/TextCell';
import HorizontalLayoutRenderer from '../../src/layouts/HorizontalLayout';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore, TestEmitter } from '../util';
Enzyme.configure({ adapter: new Adapter() });
@@ -107,15 +104,11 @@ describe('Text cell', () => {
type: 'HorizontalLayout',
elements: [firstControlElement, secondControlElement]
};
- const store = initJsonFormsVanillaStore({
- data: { firstName: 'Foo', lastName: 'Boo' },
- schema,
- uischema
- });
+ const core = initCore(schema, uischema, { firstName: 'Foo', lastName: 'Boo' });
wrapper = mount(
-
+
-
+
);
const inputs = wrapper.find('input');
expect(document.activeElement).not.toBe(inputs.at(0).getDOMNode());
@@ -128,21 +121,15 @@ describe('Text cell', () => {
scope: '#/properties/name',
options: { focus: true }
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.minLengthSchema,
- uischema
- });
+ const core = initCore(fixture.minLengthSchema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode();
expect(document.activeElement).toBe(input);
@@ -154,34 +141,22 @@ describe('Text cell', () => {
scope: '#/properties/name',
options: { focus: false }
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.minLengthSchema,
- uischema
- });
+ const core = initCore(fixture.minLengthSchema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode();
expect(document.activeElement).not.toBe(input);
});
test('autofocus inactive by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.minLengthSchema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.minLengthSchema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode();
expect(document.activeElement).not.toBe(input);
@@ -194,34 +169,22 @@ describe('Text cell', () => {
name: { type: 'string' }
}
};
- const store = initJsonFormsVanillaStore({
- data: { name: 'Foo' },
- schema,
- uischema: fixture.uischema
- });
+ const core = initCore(schema, fixture.uischema, { name: 'Foo' });
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('Foo');
});
test('has classes set', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
@@ -231,160 +194,126 @@ describe('Text cell', () => {
});
test('update via input event', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.minLengthSchema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.minLengthSchema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const input = wrapper.find('input');
input.simulate('change', { target: { value: 'Bar' } });
- expect(getData(store.getState()).name).toBe('Bar');
+ expect(onChangeData.data.name).toBe('Bar');
});
test('update via action', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.minLengthSchema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.minLengthSchema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
- store.dispatch(update('name', () => 'Bar'));
+ core.data = { ...core.data, name: 'Bar' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(input.value).toBe('Bar');
});
test('update with undefined value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.minLengthSchema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.minLengthSchema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('name', () => undefined));
+ core.data = { ...core.data, name: undefined };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('');
});
test('update with null value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.minLengthSchema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.minLengthSchema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('name', () => null));
+ core.data = { ...core.data, name: null };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('');
});
test('update with wrong ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.minLengthSchema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.minLengthSchema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('firstname', () => 'Bar'));
+ core.data = { ...core.data, firstname: 'Bar' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('Foo');
});
test('update with null ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.minLengthSchema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.minLengthSchema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update(null, () => 'Bar'));
+ core.data = { ...core.data, null: 'Bar' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('Foo');
});
test('update with undefined ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.minLengthSchema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.minLengthSchema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update(undefined, () => 'Bar'));
+ core.data = { ...core.data, undefined: 'Bar' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('Foo');
});
test('disable', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.minLengthSchema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.minLengthSchema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.disabled).toBe(true);
});
test('enabled by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.minLengthSchema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.minLengthSchema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.disabled).toBe(false);
@@ -393,24 +322,17 @@ describe('Text cell', () => {
test('use maxLength for attributes size and maxlength', () => {
const uischema: ControlElement = {
type: 'Control',
- scope: '#/properties/name'
- };
- const config = {
- restrict: true,
- trim: true
+ scope: '#/properties/name',
+ options: {
+ trim: true,
+ restrict: true
+ }
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.maxLengthSchema,
- uischema,
- config
- });
+ const core = initCore(fixture.maxLengthSchema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.maxLength).toBe(5);
@@ -420,24 +342,17 @@ describe('Text cell', () => {
test('use maxLength for attribute size only', () => {
const uischema: ControlElement = {
type: 'Control',
- scope: '#/properties/name'
- };
- const config = {
- restrict: false,
- trim: true
+ scope: '#/properties/name',
+ options: {
+ trim: true,
+ restrict: false
+ }
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.maxLengthSchema,
- uischema,
- config
- });
+ const core = initCore(fixture.maxLengthSchema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.maxLength).toBe(defaultMaxLength);
@@ -447,24 +362,17 @@ describe('Text cell', () => {
test('use maxLength for attribute max length only', () => {
const uischema: ControlElement = {
type: 'Control',
- scope: '#/properties/name'
- };
- const config = {
- restrict: true,
- trim: false
+ scope: '#/properties/name',
+ options: {
+ trim: false,
+ restrict: true
+ }
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.maxLengthSchema,
- uischema,
- config
- });
+ const core = initCore(fixture.maxLengthSchema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.maxLength).toBe(5);
@@ -472,17 +380,11 @@ describe('Text cell', () => {
});
test('do not use maxLength by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.maxLengthSchema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.maxLengthSchema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.maxLength).toBe(defaultMaxLength);
@@ -492,24 +394,17 @@ describe('Text cell', () => {
test('maxLength not specified, attributes should have default values (trim && restrict)', () => {
const uischema: ControlElement = {
type: 'Control',
- scope: '#/properties/name'
- };
- const config = {
- restrict: true,
- trim: true
+ scope: '#/properties/name',
+ options: {
+ trim: true,
+ restrict: true
+ }
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema,
- config
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.maxLength).toBe(defaultMaxLength);
@@ -519,24 +414,17 @@ describe('Text cell', () => {
test('maxLength not specified, attributes should have default values (trim)', () => {
const uischema: ControlElement = {
type: 'Control',
- scope: '#/properties/name'
- };
- const config = {
- restrict: false,
- trim: true
+ scope: '#/properties/name',
+ options: {
+ trim: true,
+ restrict: false
+ }
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema,
- config
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.maxLength).toBe(defaultMaxLength);
@@ -546,24 +434,17 @@ describe('Text cell', () => {
test('maxLength not specified, attributes should have default values (restrict)', () => {
const uischema: ControlElement = {
type: 'Control',
- scope: '#/properties/name'
- };
- const config = {
- restrict: true,
- trim: false
+ scope: '#/properties/name',
+ options: {
+ trim: false,
+ restrict: true
+ }
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema,
- config
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.maxLength).toBe(defaultMaxLength);
@@ -571,17 +452,11 @@ describe('Text cell', () => {
});
test('maxLength not specified, attributes should have default values', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.maxLength).toBe(defaultMaxLength);
diff --git a/packages/vanilla/test/renderers/TimeCell.test.tsx b/packages/vanilla/test/renderers/TimeCell.test.tsx
index a0e8f3889d..8eac0a236b 100644
--- a/packages/vanilla/test/renderers/TimeCell.test.tsx
+++ b/packages/vanilla/test/renderers/TimeCell.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -25,18 +25,15 @@
import * as React from 'react';
import {
ControlElement,
- getData,
HorizontalLayout,
JsonSchema,
- update
} from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
-import { Provider } from 'react-redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import HorizontalLayoutRenderer from '../../src/layouts/HorizontalLayout';
import TimeCell, { timeCellTester } from '../../src/cells/TimeCell';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore, TestEmitter } from '../util';
Enzyme.configure({ adapter: new Adapter() });
@@ -152,15 +149,11 @@ describe('Time cell', () => {
'firstDate': '1980-04-04',
'secondDate': '1980-04-04'
};
- const store = initJsonFormsVanillaStore({
- data,
- schema,
- uischema
- });
+ const core = initCore(schema, uischema, data);
wrapper = mount(
-
+
-
+
);
const inputs = wrapper.find('input');
expect(document.activeElement).not.toBe(inputs.at(0).getDOMNode());
@@ -175,15 +168,11 @@ describe('Time cell', () => {
focus: true
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
+
-
+
);
const input = wrapper.find('input').getDOMNode();
expect(document.activeElement).toBe(input);
@@ -197,15 +186,11 @@ describe('Time cell', () => {
focus: false
}
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
+
-
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
@@ -216,32 +201,22 @@ describe('Time cell', () => {
type: 'Control',
scope: '#/properties/foo'
};
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema
- });
+ const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
-
+
-
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.autofocus).toBe(false);
});
test('render', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
@@ -250,17 +225,11 @@ describe('Time cell', () => {
});
test('has classes set', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input');
@@ -270,159 +239,127 @@ describe('Time cell', () => {
});
test('update via event', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const onChangeData: any = {
+ data: undefined
+ };
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+ {
+ onChangeData.data = data;
+ }}
+ />
+
+
);
const input = wrapper.find('input');
input.simulate('change', { target: { value: '20:15' } });
wrapper.update();
- expect(getData(store.getState()).foo).toBe('20:15');
+ expect(onChangeData.data.foo).toBe('20:15');
});
test('update via action', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => '20:15'));
+ core.data = { ...core.data, foo: '20:15' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('20:15');
});
test('update with null value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
+
-
+
);
- store.dispatch(update('foo', () => null));
+ core.data = { ...core.data, foo: null };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('');
});
test('update with undefined value', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('foo', () => undefined));
+ core.data = { ...core.data, foo: undefined };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('');
});
test('update with wrong ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update('bar', () => 'Bar'));
+ core.data = { ...core.data, bar: 'Bar' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('13:37');
});
test('update with null ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
- store.dispatch(update(null, () => '20:15'));
+ core.data = { ...core.data, null: '20:15' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.value).toBe('13:37');
});
test('update with undefined ref', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
- store.dispatch(update(undefined, () => '20:15'));
+ core.data = { ...core.data, undefined: '20:15' };
+ wrapper.setProps({ initState: { core }} );
+ wrapper.update();
expect(input.value).toBe('13:37');
});
test('disable', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.disabled).toBe(true);
});
test('enabled by default', () => {
- const store = initJsonFormsVanillaStore({
- data: fixture.data,
- schema: fixture.schema,
- uischema: fixture.uischema
- });
+ const core = initCore(fixture.schema, fixture.uischema, fixture.data);
wrapper = mount(
-
-
-
-
-
+
+
+
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.disabled).toBe(false);
diff --git a/packages/vanilla/test/renderers/VerticalLayout.test.tsx b/packages/vanilla/test/renderers/VerticalLayout.test.tsx
index 739663015a..1de7002992 100644
--- a/packages/vanilla/test/renderers/VerticalLayout.test.tsx
+++ b/packages/vanilla/test/renderers/VerticalLayout.test.tsx
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -23,13 +23,12 @@
THE SOFTWARE.
*/
import * as React from 'react';
-import { Provider } from 'react-redux';
import { UISchemaElement, VerticalLayout } from '@jsonforms/core';
-import { JsonFormsReduxContext } from '@jsonforms/react/lib/redux';
+import { JsonFormsStateProvider } from '@jsonforms/react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { mount, ReactWrapper } from 'enzyme';
import VerticalLayoutRenderer, { verticalLayoutTester } from '../../src/layouts/VerticalLayout';
-import { initJsonFormsVanillaStore } from '../vanillaStore';
+import { initCore } from '../util';
Enzyme.configure({ adapter: new Adapter() });
@@ -50,17 +49,11 @@ describe('Vertical layout', () => {
const uischema: UISchemaElement = {
type: 'VerticalLayout'
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema,
- });
+ const core = initCore({}, uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
expect(wrapper.find('.vertical-layout')).toBeDefined();
@@ -71,17 +64,11 @@ describe('Vertical layout', () => {
type: 'VerticalLayout',
elements: null
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema
- });
+ const core = initCore({}, uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
expect(wrapper.find('.vertical-layout')).toBeDefined();
@@ -92,17 +79,11 @@ describe('Vertical layout', () => {
type: 'VerticalLayout',
elements: [{ type: 'Control' }, { type: 'Control' }]
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema
- });
+ const core = initCore({}, uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const verticalLayout = wrapper.find(VerticalLayoutRenderer).getDOMNode();
@@ -115,21 +96,15 @@ describe('Vertical layout', () => {
type: 'VerticalLayout',
elements: [{ type: 'Control' }],
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema
- });
+ const core = initCore({}, uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const verticalLayout = wrapper.find(VerticalLayoutRenderer).getDOMNode() as HTMLDivElement;
expect(verticalLayout.hidden).toBe(true);
@@ -140,18 +115,12 @@ describe('Vertical layout', () => {
type: 'VerticalLayout',
elements: [{ type: 'Control' }],
};
- const store = initJsonFormsVanillaStore({
- data: {},
- schema: {},
- uischema
- });
+ const core = initCore({}, uischema, {});
wrapper = mount(
-
-
-
-
-
+
+
+
);
const verticalLayout = wrapper.find(VerticalLayoutRenderer).getDOMNode() as HTMLDivElement;
expect(verticalLayout.hidden).toBe(false);
diff --git a/packages/vanilla/test/vanillaStore.ts b/packages/vanilla/test/util.ts
similarity index 66%
rename from packages/vanilla/test/vanillaStore.ts
rename to packages/vanilla/test/util.ts
index c4997ee4af..18673c58d6 100644
--- a/packages/vanilla/test/vanillaStore.ts
+++ b/packages/vanilla/test/util.ts
@@ -1,19 +1,19 @@
/*
The MIT License
-
+
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,39 +22,24 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-import { combineReducers, createStore, Store } from 'redux';
+
import {
- Actions,
- jsonFormsReducerConfig,
- JsonFormsState,
+ createAjv,
JsonSchema,
UISchemaElement
} from '@jsonforms/core';
+import { JsonFormsReactProps, useJsonForms } from '@jsonforms/react';
+import React from 'react';
-export const initJsonFormsVanillaStore = ({
- data,
- schema,
- uischema,
- ...other
-}: {
- data: any;
- uischema: UISchemaElement;
- schema: JsonSchema;
- [other: string]: any;
-}): Store => {
- const store: Store = createStore(
- combineReducers({
- jsonforms: combineReducers(jsonFormsReducerConfig),
- }),
- {
- // TODO
- jsonforms: {
- ...other
- } as any
- }
- );
-
- store.dispatch(Actions.init(data, schema, uischema));
+export const initCore = (schema: JsonSchema, uischema: UISchemaElement, data?: any) => {
+ return { schema, uischema, data, ajv: createAjv() };
+};
- return store;
+export const TestEmitter : React.FC = ({onChange}) => {
+ const ctx = useJsonForms();
+ const { data, errors } = ctx.core;
+ React.useEffect(() => {
+ onChange({ data, errors });
+ }, [data, errors]);
+ return null;
};