Skip to content

Commit eada273

Browse files
committed
done jumpToFirst tests
1 parent 31b30c5 commit eada273

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

tests/App.cy.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,33 @@ it('Should not jump to last target', () => {
3838
.should('not.have.class', 'active');
3939
});
4040

41-
it('Should set active clicked links without scroll interferences', () => {
42-
const targetsLength = 20;
41+
it('Should jump to first target', () => {
42+
cy.mount(App, {
43+
props: {
44+
jumpToFirst: true,
45+
marginTop: 300,
46+
},
47+
});
4348

49+
cy.get('a').eq(0).should('have.class', 'active');
50+
});
51+
52+
it('Should not jump to first target', () => {
4453
cy.mount(App, {
4554
props: {
46-
targetsLength,
55+
jumpToFirst: false,
56+
marginTop: 300,
4757
},
4858
});
4959

60+
cy.get('a').eq(0).should('not.have.class', 'active');
61+
});
62+
63+
it('Should set active clicked links without scroll interferences', () => {
64+
const targetsLength = 20;
65+
66+
cy.mount(App);
67+
5068
const randomIndices = getRandomSequence(targetsLength);
5169

5270
randomIndices.forEach((index) => {
@@ -57,12 +75,9 @@ it('Should set active clicked links without scroll interferences', () => {
5775
});
5876

5977
it('Should update targets on cancel while scrolling from click', () => {
60-
const targetsLength = 20;
61-
6278
cy.mount(App, {
6379
props: {
6480
jumpToLast: true,
65-
targetsLength,
6681
},
6782
});
6883

@@ -78,9 +93,3 @@ it('Should update targets on cancel while scrolling from click', () => {
7893
cy.wait(1000);
7994
}
8095
});
81-
82-
/* it('Should jump to first target', () => {});
83-
84-
it('Should jump to last target', () => {});
85-
86-
it('Should toggle functionalities below minWidth', () => {}); */

tests/App.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@ import { useFakeData } from '../demo/useFakeData';
44
import { useActive } from '../src/useActive';
55
66
const props = defineProps<{
7-
targetsLength: number;
87
jumpToLast: boolean;
8+
jumpToFirst: boolean;
9+
marginTop: number;
910
}>();
1011
11-
const { sections, menuItems } = useFakeData(props.targetsLength);
12+
const { sections, menuItems } = useFakeData(20);
1213
1314
const targets = computed(() => sections.map(({ id }) => id));
1415
const { setActive, isActive } = useActive(targets, {
1516
jumpToLast: props.jumpToLast,
17+
jumpToFirst: props.jumpToFirst,
1618
});
1719
</script>
1820

1921
<template>
2022
<div class="Wrapper">
21-
<div class="Content">
23+
<div class="Content" :style="`margin-top: ${marginTop || 0}px`">
2224
<section v-for="section in sections" :key="section.id">
2325
<h1 :id="section.id">{{ section.title }}</h1>
2426
<p>{{ section.text }}</p>

0 commit comments

Comments
 (0)