Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
community
pount
pount-front
Commits
2dc4e0e9
Commit
2dc4e0e9
authored
Oct 01, 2021
by
Jean Rabreau
Browse files
🚨
changed storage get method fallback
parent
0550446b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/assets/storage.js
View file @
2dc4e0e9
...
...
@@ -10,7 +10,7 @@ export default class Storage {
this
.
storage
=
storage
}
get
(
key
,
fallback
=
null
)
{
get
(
key
,
fallback
=
""
)
{
const
value
=
this
.
storage
.
getItem
(
`
${
this
.
prefix
}${
key
}
`
)
return
value
?
value
:
fallback
;
}
...
...
@@ -46,7 +46,7 @@ export default class Storage {
// update every property of state from cache
for
(
const
key
in
state
)
{
const
value
=
this
.
get
(
key
)
if
(
value
!=
null
)
state
[
key
]
=
value
if
(
value
!=
=
""
)
state
[
key
]
=
value
}
}
}
...
...
tests/unit/assets/storage.spec.js
View file @
2dc4e0e9
...
...
@@ -15,8 +15,8 @@ describe('Storage class', () => {
it
(
'
should retrieve stored value from prefixed key
'
,
()
=>
{
expect
(
storage
.
get
(
'
key
'
)).
to
.
equal
(
'
prefixedValue
'
)
})
it
(
'
should return
null
if key not stored
'
,
()
=>
{
expect
(
storage
.
get
(
'
random
'
)).
to
.
be
.
null
it
(
'
should return
empty string
if key not stored
'
,
()
=>
{
expect
(
storage
.
get
(
'
random
'
)).
to
.
equal
(
""
)
})
it
(
'
should return fallback if given and key not stored
'
,
()
=>
{
expect
(
storage
.
get
(
'
random
'
,
'
des choux
'
)).
to
.
equal
(
'
des choux
'
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment