aboutsummaryrefslogtreecommitdiff
path: root/test/unit/specs/services/theme_data/iss_deserializer.spec.js
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2024-09-26 01:10:57 +0300
committerHenry Jameson <me@hjkos.com>2024-09-26 01:10:57 +0300
commit6fc929a0a040bfdf3b403c5f2b708ab4a51fe2e8 (patch)
treec85c68d9e09826a9d81b4ef21706f782c5a9a5d6 /test/unit/specs/services/theme_data/iss_deserializer.spec.js
parent22cc96705ab3af42a6373ccab6df473ba1243fed (diff)
parent05c0b16a935c2799ece31845897d3a29d39e3eee (diff)
Merge remote-tracking branch 'origin/develop' into shadow-control-2.0
Diffstat (limited to 'test/unit/specs/services/theme_data/iss_deserializer.spec.js')
-rw-r--r--test/unit/specs/services/theme_data/iss_deserializer.spec.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/unit/specs/services/theme_data/iss_deserializer.spec.js b/test/unit/specs/services/theme_data/iss_deserializer.spec.js
new file mode 100644
index 00000000..6eb25dfe
--- /dev/null
+++ b/test/unit/specs/services/theme_data/iss_deserializer.spec.js
@@ -0,0 +1,40 @@
+import { deserialize } from 'src/services/theme_data/iss_deserializer.js'
+import { serialize } from 'src/services/theme_data/iss_serializer.js'
+const componentsContext = require.context('src', true, /\.style.js(on)?$/)
+
+describe('ISS (de)serialization', () => {
+ componentsContext.keys().forEach(key => {
+ const component = componentsContext(key).default
+
+ it(`(De)serialization of component ${component.name} works`, () => {
+ const normalized = component.defaultRules.map(x => ({ component: component.name, ...x }))
+ const serialized = serialize(normalized)
+ const deserialized = deserialize(serialized)
+
+ // for some reason comparing objects directly fails the assert
+ expect(JSON.stringify(deserialized, null, 2)).to.equal(JSON.stringify(normalized, null, 2))
+ })
+ })
+
+ /*
+ // Debug snippet
+ const onlyComponent = componentsContext('./components/panel_header.style.js').default
+ it.only(`(De)serialization of component ${onlyComponent.name} works`, () => {
+ const normalized = onlyComponent.defaultRules.map(x => ({ component: onlyComponent.name, ...x }))
+ console.log('BEGIN INPUT ================')
+ console.log(normalized)
+ console.log('END INPUT ==================')
+ const serialized = serialize(normalized)
+ console.log('BEGIN SERIAL ===============')
+ console.log(serialized)
+ console.log('END SERIAL =================')
+ const deserialized = deserialize(serialized)
+ console.log('BEGIN DESERIALIZED =========')
+ console.log(serialized)
+ console.log('END DESERIALIZED ===========')
+
+ // for some reason comparing objects directly fails the assert
+ expect(JSON.stringify(deserialized, null, 2)).to.equal(JSON.stringify(normalized, null, 2))
+ })
+ /* */
+})