Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0361f42c
Commit
0361f42c
authored
Mar 12, 2021
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added specs to util methods
parent
d16914b7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
spec/frontend/emoji/components/utils_spec.js
spec/frontend/emoji/components/utils_spec.js
+56
-0
No files found.
spec/frontend/emoji/components/utils_spec.js
0 → 100644
View file @
0361f42c
import
Cookies
from
'
js-cookie
'
;
import
{
getFrequentlyUsedEmojis
,
addToFrequentlyUsed
}
from
'
~/emoji/components/utils
'
;
jest
.
mock
(
'
js-cookie
'
);
describe
(
'
getFrequentlyUsedEmojis
'
,
()
=>
{
it
(
'
it returns null when no saved emojis set
'
,
()
=>
{
jest
.
spyOn
(
Cookies
,
'
get
'
).
mockReturnValue
(
null
);
expect
(
getFrequentlyUsedEmojis
()).
toBe
(
null
);
});
it
(
'
it returns frequently used emojis object
'
,
()
=>
{
jest
.
spyOn
(
Cookies
,
'
get
'
).
mockReturnValue
(
'
thumbsup,thumbsdown
'
);
expect
(
getFrequentlyUsedEmojis
()).
toEqual
({
frequently_used
:
{
emojis
:
[[
'
thumbsup
'
,
'
thumbsdown
'
]],
top
:
0
,
height
:
71
,
},
});
});
});
describe
(
'
addToFrequentlyUsed
'
,
()
=>
{
it
(
'
sets cookie value
'
,
()
=>
{
jest
.
spyOn
(
Cookies
,
'
get
'
).
mockReturnValue
(
null
);
addToFrequentlyUsed
(
'
thumbsup
'
);
expect
(
Cookies
.
set
).
toHaveBeenCalledWith
(
'
frequently_used_emojis
'
,
'
thumbsup
'
,
{
expires
:
365
,
});
});
it
(
'
sets cookie value to include previously set cookie value
'
,
()
=>
{
jest
.
spyOn
(
Cookies
,
'
get
'
).
mockReturnValue
(
'
thumbsdown
'
);
addToFrequentlyUsed
(
'
thumbsup
'
);
expect
(
Cookies
.
set
).
toHaveBeenCalledWith
(
'
frequently_used_emojis
'
,
'
thumbsdown,thumbsup
'
,
{
expires
:
365
,
});
});
it
(
'
sets cookie value with uniq values
'
,
()
=>
{
jest
.
spyOn
(
Cookies
,
'
get
'
).
mockReturnValue
(
'
thumbsup
'
);
addToFrequentlyUsed
(
'
thumbsup
'
);
expect
(
Cookies
.
set
).
toHaveBeenCalledWith
(
'
frequently_used_emojis
'
,
'
thumbsup
'
,
{
expires
:
365
,
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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