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
425d9471
Commit
425d9471
authored
Dec 23, 2019
by
Martin Wortschack
Committed by
Phil Hughes
Dec 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace breakpoints with GlBreakpointInstance in frequent_items/utils.js
parent
b986e80a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
app/assets/javascripts/frequent_items/utils.js
app/assets/javascripts/frequent_items/utils.js
+2
-6
spec/javascripts/frequent_items/utils_spec.js
spec/javascripts/frequent_items/utils_spec.js
+12
-6
No files found.
app/assets/javascripts/frequent_items/utils.js
View file @
425d9471
import
_
from
'
underscore
'
;
import
bp
from
'
~/breakpoint
s
'
;
import
{
GlBreakpointInstance
as
bp
}
from
'
@gitlab/ui/dist/util
s
'
;
import
{
FREQUENT_ITEMS
,
HOUR_IN_MS
}
from
'
./constants
'
;
export
const
isMobile
=
()
=>
{
const
screenSize
=
bp
.
getBreakpointSize
();
return
screenSize
===
'
sm
'
||
screenSize
===
'
xs
'
;
};
export
const
isMobile
=
()
=>
[
'
md
'
,
'
sm
'
,
'
xs
'
].
includes
(
bp
.
getBreakpointSize
());
export
const
getTopFrequentItems
=
items
=>
{
if
(
!
items
)
{
...
...
spec/javascripts/frequent_items/utils_spec.js
View file @
425d9471
import
bp
from
'
~/breakpoint
s
'
;
import
{
GlBreakpointInstance
as
bp
}
from
'
@gitlab/ui/dist/util
s
'
;
import
{
isMobile
,
getTopFrequentItems
,
updateExistingFrequentItem
}
from
'
~/frequent_items/utils
'
;
import
{
HOUR_IN_MS
,
FREQUENT_ITEMS
}
from
'
~/frequent_items/constants
'
;
import
{
mockProject
,
unsortedFrequentItems
,
sortedFrequentItems
}
from
'
./mock_data
'
;
describe
(
'
Frequent Items utils spec
'
,
()
=>
{
describe
(
'
isMobile
'
,
()
=>
{
it
(
'
returns true when the screen is medium
'
,
()
=>
{
spyOn
(
bp
,
'
getBreakpointSize
'
).
and
.
returnValue
(
'
md
'
);
expect
(
isMobile
()).
toBe
(
true
);
});
it
(
'
returns true when the screen is small
'
,
()
=>
{
spyOn
(
bp
,
'
getBreakpointSize
'
).
and
.
returnValue
(
'
sm
'
);
...
...
@@ -17,8 +23,8 @@ describe('Frequent Items utils spec', () => {
expect
(
isMobile
()).
toBe
(
true
);
});
it
(
'
returns false when the screen is larger than
small
'
,
()
=>
{
spyOn
(
bp
,
'
getBreakpointSize
'
).
and
.
returnValue
(
'
md
'
);
it
(
'
returns false when the screen is larger than
medium
'
,
()
=>
{
spyOn
(
bp
,
'
getBreakpointSize
'
).
and
.
returnValue
(
'
lg
'
);
expect
(
isMobile
()).
toBe
(
false
);
});
...
...
@@ -32,21 +38,21 @@ describe('Frequent Items utils spec', () => {
});
it
(
'
returns correct amount of items for mobile
'
,
()
=>
{
spyOn
(
bp
,
'
getBreakpointSize
'
).
and
.
returnValue
(
'
sm
'
);
spyOn
(
bp
,
'
getBreakpointSize
'
).
and
.
returnValue
(
'
md
'
);
const
result
=
getTopFrequentItems
(
unsortedFrequentItems
);
expect
(
result
.
length
).
toBe
(
FREQUENT_ITEMS
.
LIST_COUNT_MOBILE
);
});
it
(
'
returns correct amount of items for desktop
'
,
()
=>
{
spyOn
(
bp
,
'
getBreakpointSize
'
).
and
.
returnValue
(
'
lg
'
);
spyOn
(
bp
,
'
getBreakpointSize
'
).
and
.
returnValue
(
'
xl
'
);
const
result
=
getTopFrequentItems
(
unsortedFrequentItems
);
expect
(
result
.
length
).
toBe
(
FREQUENT_ITEMS
.
LIST_COUNT_DESKTOP
);
});
it
(
'
sorts frequent items in order of frequency and lastAccessedOn
'
,
()
=>
{
spyOn
(
bp
,
'
getBreakpointSize
'
).
and
.
returnValue
(
'
lg
'
);
spyOn
(
bp
,
'
getBreakpointSize
'
).
and
.
returnValue
(
'
xl
'
);
const
result
=
getTopFrequentItems
(
unsortedFrequentItems
);
const
expectedResult
=
sortedFrequentItems
.
slice
(
0
,
FREQUENT_ITEMS
.
LIST_COUNT_DESKTOP
);
...
...
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