1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-22 01:03:20 +01:00

test tweaks, switch to strict mode

This commit is contained in:
Matthias Kretschmann 2024-02-06 01:42:05 +00:00
parent 408d9f96f3
commit e6d1f8dc56
Signed by: m
GPG Key ID: 606EEEF3C479A91F
6 changed files with 12 additions and 7 deletions

View File

@ -44,7 +44,7 @@ export default function Icon({ name, ...props }: { name: string }) {
Contrast
}
const IconMapped = components[name]
const IconMapped = components[name as keyof typeof components]
return IconMapped ? (
<IconMapped className={`${styles.icon} ${styles[name]}`} {...props} />

View File

@ -18,7 +18,7 @@ function Animation({ children }: { children: React.ReactNode }) {
aria-label="Location"
variants={fadeIn}
className={styles.location}
{...getAnimationProps(shouldReduceMotion)}
{...getAnimationProps(shouldReduceMotion || false)}
>
{children}
</m.section>

View File

@ -18,9 +18,13 @@ export default function ProjectNav({ projects, currentSlug }: Props) {
useEffect(() => {
function scrollToCurrent() {
if (!scrollContainer.current || !currentItem.current) return
const activeItem = currentItem.current
const scrollRect = scrollContainer.current?.getBoundingClientRect()
const scrollRect = scrollContainer.current.getBoundingClientRect()
const activeRect = activeItem && activeItem.getBoundingClientRect()
if (!activeItem || !scrollRect || !activeRect) return
const newScrollLeftPosition =
activeRect &&
activeRect.left -

View File

@ -23,7 +23,7 @@ describe('imageToDataUrl', () => {
})
it('should convert image to data URL', async () => {
function MockFileReader() {
function MockFileReader(this: any) {
this.readAsDataURL = function () {
this.result = 'data:image/png;base64,...'
setTimeout(() => this.onload(), 0)
@ -33,11 +33,12 @@ describe('imageToDataUrl', () => {
window.FileReader = MockFileReader as any
const dataUrl = await imageToDataUrl(dummyPath)
expect(dataUrl).toBe('data:image/png;base64,...')
})
it('should handle errors in readAsDataURL', async () => {
function MockFileReader() {
function MockFileReader(this: FileReader) {
this.readAsDataURL = function () {
throw new Error('Mock error')
}

View File

@ -5,7 +5,7 @@ import { getRepos } from './getRepos'
jest.mock('react', () => ({
...jest.requireActual('react'),
cache: (fn) => fn
cache: (fn: any) => fn
}))
describe('getRepos', () => {

View File

@ -4,7 +4,7 @@
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false, // TODO: Change to strict: true
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,