From cc6c8b2b387639387b9871be6715cb0c0475bf8a Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Tue, 29 Dec 2020 00:54:15 +0300 Subject: [PATCH] Add tests for function that checks if setting follows rules --- .../settings/settingFollowsRules.test.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/views/settings/settingFollowsRules.test.js diff --git a/test/views/settings/settingFollowsRules.test.js b/test/views/settings/settingFollowsRules.test.js new file mode 100644 index 00000000..a67745c2 --- /dev/null +++ b/test/views/settings/settingFollowsRules.test.js @@ -0,0 +1,35 @@ +import { settingFollowsRules } from '@/views/settings/rules' + +describe('Check if settings follow rules', () => { + it('does not render :proxy_remote when local :uploader is selected', () => { + const state = { ':pleroma': { 'Pleroma.Upload': { ':uploader': 'Pleroma.Uploaders.Local' }}} + + expect(settingFollowsRules(':proxy_remote', 'Pleroma.Upload', state)).toBeFalsy() + }) + + it('render :proxy_remote when local :uploader is not selected', () => { + const state = { ':pleroma': { 'Pleroma.Upload': { ':uploader': 'Pleroma.Uploaders.S3' }}} + + expect(settingFollowsRules(':proxy_remote', 'Pleroma.Upload', state)).toBeTruthy() + }) + + it('render setting when there is no rule', () => { + const state = { ':pleroma': { 'Pleroma.Upload': { ':uploader': 'Pleroma.Uploaders.Local' }}} + + expect(settingFollowsRules(':filters', 'Pleroma.Upload', state)).toBeTruthy() + }) + + it('render setting when one of the keys is undefined', () => { + const state = { ':pleroma': {}} + + expect(settingFollowsRules(':level', undefined, state)).toBeTruthy() + + expect(settingFollowsRules(':admin_token', undefined, state)).toBeTruthy() + }) + + it('render setting when state is empty', () => { + const state = { ':pleroma': { 'Pleroma.Upload': {}}} + + expect(settingFollowsRules(':proxy_remote', 'Pleroma.Upload', state)).toBeTruthy() + }) +}) \ No newline at end of file