Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
admin-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
admin-fe
Commits
58760ac4
Commit
58760ac4
authored
5 years ago
by
Angelina Filippova
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for wrapping setting without keys
parent
eabc4464
No related branches found
Branches containing commit
No related tags found
1 merge request
!65
Update server configuration
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/modules/normalizers/checkPartialUpdate.test.js
+21
-21
21 additions, 21 deletions
test/modules/normalizers/checkPartialUpdate.test.js
test/modules/normalizers/wrapUpdatedSettings.test.js
+42
-0
42 additions, 0 deletions
test/modules/normalizers/wrapUpdatedSettings.test.js
with
63 additions
and
21 deletions
test/modules/normalizers/checkPartialUpdate.test.js
+
21
−
21
View file @
58760ac4
...
...
@@ -4,44 +4,44 @@ import _ from 'lodash'
describe
(
'
Partial update
'
,
()
=>
{
it
(
'
partial update for settings that do not allow partial update
'
,
()
=>
{
const
settings
=
{
'
:auto_linker
'
:
{
'
:opts
'
:
{
'
:strip_prefix
'
:
true
,
'
:new_window
'
:
false
,
'
:rel
'
:
"
ugc
"
,
'
:truncate
'
:
3
}
{
'
:strip_prefix
'
:
true
,
'
:new_window
'
:
false
,
'
:rel
'
:
'
ugc
'
,
'
:truncate
'
:
3
}
}}
const
updatedSettings
=
{
'
:auto_linker
'
:
{
'
:opts
'
:
{
'
:new_window
'
:
false
}}}
const
description
=
[{
children
:
[
{
key
:
"
:strip_prefix
"
,
type
:
"
boolean
"
},
{
key
:
"
:truncate
"
,
type
:
[
"
integer
"
,
false
]
},
{
key
:
"
:new_window
"
,
type
:
"
boolean
"
}],
description
:
"
Configuration for the auto_linker library
"
,
group
:
"
:auto_linker
"
,
key
:
"
:opts
"
,
label
:
"
Opts
"
,
type
:
"
group
"
{
key
:
'
:strip_prefix
'
,
type
:
'
boolean
'
},
{
key
:
'
:truncate
'
,
type
:
[
'
integer
'
,
false
]
},
{
key
:
'
:new_window
'
,
type
:
'
boolean
'
}],
description
:
'
Configuration for the auto_linker library
'
,
group
:
'
:auto_linker
'
,
key
:
'
:opts
'
,
label
:
'
Opts
'
,
type
:
'
group
'
}]
const
expectedData
=
{
'
:auto_linker
'
:
{
'
:opts
'
:
{
'
:strip_prefix
'
:
[
"
boolean
"
,
true
],
'
:new_window
'
:
[
"
boolean
"
,
false
],
'
:rel
'
:
[
''
,
"
ugc
"
],
'
:truncate
'
:
[[
"
integer
"
,
false
],
3
]
'
:strip_prefix
'
:
[
'
boolean
'
,
true
],
'
:new_window
'
:
[
'
boolean
'
,
false
],
'
:rel
'
:
[
''
,
'
ugc
'
],
'
:truncate
'
:
[[
'
integer
'
,
false
],
3
]
}}}
const
updatedData
=
checkPartialUpdate
(
settings
,
updatedSettings
,
description
)
expect
(
_
.
isEqual
(
updatedData
,
expectedData
)).
toBeTruthy
()
})
it
(
'
partial update for settings that allow partial update
'
,
()
=>
{
const
settings
=
{
'
:pleroma
'
:
{
'
Pleroma.Captcha
'
:
{
'
:enabled
'
:
true
,
'
:seconds_valid
'
:
70
,
'
:method
'
:
"
Pleroma.Captcha.Kocaptcha
"
}}}
const
updatedSettings
=
{
'
:pleroma
'
:
{
'
Pleroma.Captcha
'
:
{
'
:seconds_valid
'
:
[
"
integer
"
,
70
]
}}}
const
settings
=
{
'
:pleroma
'
:
{
'
Pleroma.Captcha
'
:
{
'
:enabled
'
:
true
,
'
:seconds_valid
'
:
70
,
'
:method
'
:
'
Pleroma.Captcha.Kocaptcha
'
}}}
const
updatedSettings
=
{
'
:pleroma
'
:
{
'
Pleroma.Captcha
'
:
{
'
:seconds_valid
'
:
[
'
integer
'
,
70
]
}}}
const
description
=
[{
children
:
[],
description
:
"
Captcha-related settings
"
,
group
:
"
:pleroma
"
,
key
:
"
Pleroma.Captcha
"
,
label
:
"
Pleroma.Captcha
"
,
type
:
"
group
"
description
:
'
Captcha-related settings
'
,
group
:
'
:pleroma
'
,
key
:
'
Pleroma.Captcha
'
,
label
:
'
Pleroma.Captcha
'
,
type
:
'
group
'
}]
const
expectedData
=
{
'
:pleroma
'
:
{
'
Pleroma.Captcha
'
:
{
'
:seconds_valid
'
:
[
"
integer
"
,
70
]
}}}
const
expectedData
=
{
'
:pleroma
'
:
{
'
Pleroma.Captcha
'
:
{
'
:seconds_valid
'
:
[
'
integer
'
,
70
]
}}}
const
updatedData
=
checkPartialUpdate
(
settings
,
updatedSettings
,
description
)
expect
(
_
.
isEqual
(
updatedData
,
expectedData
)).
toBeTruthy
()
})
...
...
This diff is collapsed.
Click to expand it.
test/modules/normalizers/wrapUpdatedSettings.test.js
0 → 100644
+
42
−
0
View file @
58760ac4
import
{
wrapUpdatedSettings
}
from
'
@/store/modules/normalizers
'
import
_
from
'
lodash
'
describe
(
'
Wrap settings
'
,
()
=>
{
it
(
'
wraps values without keys with type atom
'
,
()
=>
{
const
settings
=
{
'
:level
'
:
{
_value
:
[
'
atom
'
,
'
warn
'
]
}}
const
result
=
wrapUpdatedSettings
(
'
:quack
'
,
settings
,
{})
const
expectedResult
=
[{
group
:
'
:quack
'
,
key
:
'
:level
'
,
value
:
'
:warn
'
}]
expect
(
_
.
isEqual
(
result
,
expectedResult
)).
toBeTruthy
()
})
it
(
'
wraps :backends setting in group :logger
'
,
()
=>
{
const
settings
=
{
'
:backends
'
:
{
_value
:
[[
'
atom
'
,
'
tuple
'
,
'
module
'
],
[
'
:console
'
,
'
Quack.Logger
'
,
'
:ex_syslogger
'
]]
}}
const
result
=
wrapUpdatedSettings
(
'
:logger
'
,
settings
,
{})
const
expectedResult
=
[{
group
:
'
:logger
'
,
key
:
'
:backends
'
,
value
:
[
'
:console
'
,
'
Quack.Logger
'
,
{
'
tuple
'
:
[
'
ExSyslogger
'
,
'
:ex_syslogger
'
]
}]
}]
expect
(
_
.
isEqual
(
result
,
expectedResult
)).
toBeTruthy
()
})
it
(
'
wraps :types setting in group :mime
'
,
()
=>
{
const
settings
=
{
'
:types
'
:
{
_value
:
[
'
map
'
,
{
'
application/ld+json
'
:
[[
'
list
'
,
'
string
'
],
[
'
activity+json
'
]],
'
application/xml
'
:
[[
'
list
'
,
'
string
'
],
[
'
xml
'
]],
'
application/xrd+xml
'
:
[[
'
list
'
,
'
string
'
],
[
'
xrd+xml
'
]]
}]}}
const
result
=
wrapUpdatedSettings
(
'
:mime
'
,
settings
,
{})
const
expectedResult
=
[{
group
:
'
:mime
'
,
key
:
'
:types
'
,
value
:
{
'
application/ld+json
'
:
[
'
activity+json
'
],
'
application/xml
'
:
[
'
xml
'
],
'
application/xrd+xml
'
:
[
'
xrd+xml
'
]
}
}]
expect
(
_
.
isEqual
(
result
,
expectedResult
)).
toBeTruthy
()
})
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment