Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sparesti-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
idatt2106_2024_01
sparesti-frontend
Merge requests
!98
Styling generate new challenge view
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Styling generate new challenge view
styling-generate-new-challenge-view
into
development
Overview
0
Commits
4
Pipelines
1
Changes
3
Merged
Håkon Rene Billingstad
requested to merge
styling-generate-new-challenge-view
into
development
1 year ago
Overview
0
Commits
4
Pipelines
1
Changes
3
Expand
0
0
Merge request reports
Compare
development
development (base)
and
latest version
latest version
c9bac6dc
4 commits,
1 year ago
3 files
+
102
−
2
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
src/components/ui/carousel/__tests__/useCarousel.spec.js
0 → 100644
+
62
−
0
Options
import
{
describe
,
it
,
expect
,
vi
}
from
'
vitest
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
createApp
,
ref
}
from
'
vue
'
;
import
{
useProvideCarousel
,
useCarousel
}
from
'
/src/components/ui/carousel/useCarousel.js
'
;
// Adjust the path as necessary
// Mock the emblaCarouselVue import
vi
.
mock
(
'
embla-carousel-vue
'
,
()
=>
{
const
on
=
vi
.
fn
();
const
scrollPrev
=
vi
.
fn
();
const
scrollNext
=
vi
.
fn
();
const
canScrollNext
=
()
=>
true
;
const
canScrollPrev
=
()
=>
true
;
const
api
=
{
on
,
scrollPrev
,
scrollNext
,
canScrollNext
,
canScrollPrev
};
return
{
default
:
()
=>
[
ref
(),
// emblaNode
ref
(
api
)
// emblaApi
]
};
});
describe
(
'
Carousel Logic
'
,
()
=>
{
it
(
'
throws error when useCarousel is used outside of Carousel provider
'
,
()
=>
{
expect
(()
=>
{
mount
({
template
:
'
<div></div>
'
,
setup
()
{
return
useCarousel
();
}
});
}).
toThrow
(
'
useCarousel must be used within a <Carousel />
'
);
});
it
(
'
scrollPrev and scrollNext methods are callable
'
,
async
()
=>
{
const
wrapper
=
mount
({
template
:
'
<div><div ref="carouselRef"></div></div>
'
,
setup
()
{
const
{
scrollPrev
,
scrollNext
}
=
useProvideCarousel
({
opts
:
{},
orientation
:
'
horizontal
'
,
plugins
:
[]
},
vi
.
fn
());
return
{
scrollPrev
,
scrollNext
};
}
});
await
wrapper
.
vm
.
scrollPrev
();
await
wrapper
.
vm
.
scrollNext
();
// Assertions to check if the methods are callable and working as expected
});
});
Loading