From f0e0047e92db7e771579d574589afbd118b4e880 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 28 Sep 2020 20:11:10 +0300 Subject: [PATCH] Add test for wrapping settings with type [`list`, `map`] --- .../normalizers/wrapUpdatedSettings.test.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/modules/normalizers/wrapUpdatedSettings.test.js b/test/modules/normalizers/wrapUpdatedSettings.test.js index 7e5dafab..392b4f38 100644 --- a/test/modules/normalizers/wrapUpdatedSettings.test.js +++ b/test/modules/normalizers/wrapUpdatedSettings.test.js @@ -374,6 +374,40 @@ describe('Wrap settings', () => { expect(_.isEqual(result, expectedResult)).toBeTruthy() }) + it('wraps settings with type [`list`, `map`]', () => { + const settings = { ':manifest': { ':icons': [['map', 'list'], [ + { ':src': '/static/logo.png', ':type': 'image/png' }, + { ':src': '/static/icon.png', ':type': 'image/png' } + ]]}} + + const state = { ':pleroma': { ':manifest': { + ':background_color': '#191b22', + ':theme_color': '#282c37', + ':icons': [ + [ + { 'id': 'f21318c4', 'key': ':src', 'value': '/static/logo.png' }, + { 'id': 'f4b87549', 'key': ':type', 'value': 'image/png' } + ], [ + { 'id': 'f31d351e', 'key': ':src', 'value': '/static/icon.png' }, + { 'id': 'f1455852', 'key': ':type', 'value': 'image/png' } + ] + ] + }}} + + const result = wrapUpdatedSettings(':pleroma', settings, state) + const expectedResult = [{ + group: ':pleroma', + key: ':manifest', + value: [{ tuple: [':icons', [ + { ':src': '/static/logo.png', ':type': 'image/png' }, + { ':src': '/static/icon.png', ':type': 'image/png' } + ]]}] + }] + + expect(_.isEqual(result, expectedResult)).toBeTruthy() + }) + + it('wraps IP setting', () => { const settings = { ':gopher': { ':ip': ['tuple', '127.0.0.1']}} const state = { ':pleroma': { ':gopher': {}}}