aboutsummaryrefslogtreecommitdiff
path: root/test/unit/specs
diff options
context:
space:
mode:
authorHJ <30-hj@users.noreply.git.pleroma.social>2024-09-21 08:18:23 +0000
committerHJ <30-hj@users.noreply.git.pleroma.social>2024-09-21 08:18:23 +0000
commitf127ae307b3a444f13c6f8b75ba99cf61244677e (patch)
tree9eff1b20ae2ab270c301e5555e9d4103c888f18b /test/unit/specs
parent23f8c08809d2ad38780584ef4f46643772cf5efe (diff)
parent14328917f1a25770f90dc2181fad090ace4954da (diff)
Merge branch 'piss-serialization' into 'develop'
Pleroma ISS (interface stylesheets) implementation See merge request pleroma/pleroma-fe!1943
Diffstat (limited to 'test/unit/specs')
-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..01f8dacf
--- /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(`(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))
+ })
+ */
+})