diff --git a/test/modules/normalizers/wrapUpdatedSettings.test.js b/test/modules/normalizers/wrapUpdatedSettings.test.js index 00310f888311eb8db9f057c42da304a017adf05c..1a294bb255a860535c59f4c131007308deeba969 100644 --- a/test/modules/normalizers/wrapUpdatedSettings.test.js +++ b/test/modules/normalizers/wrapUpdatedSettings.test.js @@ -228,7 +228,7 @@ describe('Wrap settings', () => { expect(_.isEqual(result2, expectedResult2)).toBeTruthy() }) - it('wraps settings with type tuple and atom', () => { + it('wraps settings with type atom and tuple', () => { const settings1 = { 'Oban': { ':prune': [["atom", "tuple"], ":disabled"]}} const state1 = { ':pleroma': { 'Oban': {}}} const result1 = wrapUpdatedSettings(':pleroma', settings1, state1) @@ -252,4 +252,71 @@ describe('Wrap settings', () => { expect(_.isEqual(result1, expectedResult1)).toBeTruthy() expect(_.isEqual(result2, expectedResult2)).toBeTruthy() }) + + it('wraps settings with type map', () => { + const settings1 = { ':instance': { ':poll_limits': ["map", { ":min_expiration": ["integer", 100] }]}} + const state1 = { ':pleroma': { ':instance': { ':poll_limits': { + ':max_expiration': 31536000, + ':max_option_chars': 200, + ':max_options': 20, + ':min_expiration': 100 + }}}} + const result1 = wrapUpdatedSettings(':pleroma', settings1, state1) + const expectedResult1 = [{ + group: ':pleroma', + key: ":instance", + value: [{ tuple: [":poll_limits", { + ':max_expiration': 31536000, + ":max_option_chars": 200, + ":max_options": 20, + ":min_expiration": 100 + }]}] + }] + + const settings2 = { ':email_notifications': { ':digest': ["map", { + ':active': ["boolean", true], + ':schedule': ["string", "0 0 0"], + ':inactivity_threshold': ["integer", 10] + }]}} + const state2 = { ':pleroma': { ':email_notifications': { ':digest': { + ':active': true, + ':inactivity_threshold': 10, + ':interval': 7, + ':schedule': "0 0 0" + }}}} + const result2 = wrapUpdatedSettings(':pleroma', settings2, state2) + const expectedResult2 = [{ + group: ':pleroma', + key: ":email_notifications", + value: [{ tuple: [":digest", { + ':active': true, + ':inactivity_threshold': 10, + ':interval': 7, + ':schedule': "0 0 0" + }]}] + }] + + const settings3 = { ':mrf_subchain': { ':match_actor': ["map", { + '~r/https:\/\/example.com/s': ["Elixir.Pleroma.Web.ActivityPub.MRF.DropPolicy"], + '~r/https:\/\/test.com': ["Elixir.Pleroma.Web.ActivityPub.MRF.TestPolicy"] + }]}} + const state3 = { ':pleroma': { ':mrf_subchain': { ':match_actor': [ + { '~r/https:\/\/example.com/s': ["Elixir.Pleroma.Web.ActivityPub.MRF.DropPolicy"] }, + { '~r/https:\/\/test.com': ["Elixir.Pleroma.Web.ActivityPub.MRF.TestPolicy"] } + ] + }}} + const result3 = wrapUpdatedSettings(':pleroma', settings3, state3) + const expectedResult3 = [{ + group: ':pleroma', + key: ":mrf_subchain", + value: [{ tuple: [":match_actor", { + '~r/https:\/\/example.com/s': ["Elixir.Pleroma.Web.ActivityPub.MRF.DropPolicy"], + '~r/https:\/\/test.com': ["Elixir.Pleroma.Web.ActivityPub.MRF.TestPolicy"] + }]}] + }] + + expect(_.isEqual(result1, expectedResult1)).toBeTruthy() + expect(_.isEqual(result2, expectedResult2)).toBeTruthy() + expect(_.isEqual(result3, expectedResult3)).toBeTruthy() + }) })