chore: add vitest/globals types, remove redundant vitest imports, fix pre-existing lint issues
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
export type { NavItem } from './model/types';
|
||||
export { MobileNav } from './ui/MobileNav';
|
||||
export { SidebarNav } from './ui/SidebarNav';
|
||||
export { UtilityBar } from './ui/UtilityBar';
|
||||
export type { NavItem } from './model/types';
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { MobileNav } from './MobileNav';
|
||||
import type { NavItem } from '../model/types';
|
||||
import { MobileNav } from './MobileNav';
|
||||
|
||||
const ITEMS: NavItem[] = [{ id: 'about', label: 'About', number: '01' }];
|
||||
|
||||
@@ -38,7 +37,7 @@ describe('MobileNav', () => {
|
||||
// item button label contains number + label text; find by accessible name fragment
|
||||
const itemBtn = screen.getAllByRole('button').find((b) => b.textContent?.includes('About'));
|
||||
expect(itemBtn).toBeDefined();
|
||||
await userEvent.click(itemBtn!);
|
||||
await userEvent.click(itemBtn as HTMLElement);
|
||||
expect(screen.queryByText('Close')).not.toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Menu' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -34,6 +34,7 @@ export function MobileNav({ items }: Props) {
|
||||
<div className="px-6 py-4 flex items-center justify-between">
|
||||
<h4>allmy.work</h4>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsOpen((prev) => !prev)}
|
||||
className="brutal-border px-4 py-2 bg-carbon-black text-ochre-clay"
|
||||
>
|
||||
@@ -44,6 +45,7 @@ export function MobileNav({ items }: Props) {
|
||||
<div className="px-6 py-6 brutal-border-top space-y-2 max-h-[80vh] overflow-y-auto">
|
||||
{items.map((item) => (
|
||||
<button
|
||||
type="button"
|
||||
key={item.id}
|
||||
onClick={() => scrollToSection(item.id)}
|
||||
className="w-full text-left brutal-border bg-ochre-clay px-4 py-3"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import type { NavItem } from '../model/types';
|
||||
import { SidebarNav } from './SidebarNav';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { cn } from '$shared/lib';
|
||||
import type { NavItem } from '../model/types';
|
||||
|
||||
@@ -31,7 +31,9 @@ export function SidebarNav({ items }: Props) {
|
||||
|
||||
items.forEach((item) => {
|
||||
const el = document.getElementById(item.id);
|
||||
if (el) observer.observe(el);
|
||||
if (el) {
|
||||
observer.observe(el);
|
||||
}
|
||||
});
|
||||
|
||||
return () => observer.disconnect();
|
||||
@@ -62,6 +64,7 @@ export function SidebarNav({ items }: Props) {
|
||||
const isActive = activeSection === item.id;
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
key={item.id}
|
||||
onClick={() => scrollToSection(item.id)}
|
||||
className={cn(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { UtilityBar } from './UtilityBar';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user