From 290ca32fd65699f4e9398c05510439bb3d2e2202 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 20 Jul 2020 12:56:01 +0300 Subject: [PATCH] Add test for parsing options setting in MediaProxy.Invalidation.Http group --- test/modules/normalizers/parseTuples.test.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/modules/normalizers/parseTuples.test.js b/test/modules/normalizers/parseTuples.test.js index 2092f437..9cbe9d2f 100644 --- a/test/modules/normalizers/parseTuples.test.js +++ b/test/modules/normalizers/parseTuples.test.js @@ -240,6 +240,26 @@ describe('Parse tuples', () => { expect(_.isEqual(expectedResult, result)).toBeTruthy() }) + it('parses options setting in MediaProxy.Invalidation.Http group', () => { + const tuples = [{ tuple: [":options", [{ tuple: [":params", { xxx: "zzz", aaa: "bbb" }]}]]}] + const expectedResult = { ':options': { ':params': + [ { xxx: { value: 'zzz' }}, { aaa: { value: 'bbb' }}] + }} + + const parsed = parseTuples(tuples, 'Pleroma.Web.MediaProxy.Invalidation.Http') + + expect(typeof parsed).toBe('object') + expect(':options' in parsed).toBeTruthy() + + const idRemoved = parsed[':options'][':params'].map(el => { + const key = Object.keys(el)[0] + const { id, ...rest } = el[key] + return { [key]: rest } + }) + parsed[':options'][':params'] = idRemoved + expect(_.isEqual(expectedResult, parsed)).toBeTruthy() + }) + it('parses proxy_url', () => { const proxyUrlNull = [{ tuple: [":proxy_url", null] }] const proxyUrlTuple = [{ tuple: [":proxy_url", { tuple: [":socks5", ":localhost", 3090] }]}]