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:
parent
408d9f96f3
commit
e6d1f8dc56
@ -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} />
|
||||
|
@ -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>
|
||||
|
@ -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 -
|
||||
|
@ -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')
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import { getRepos } from './getRepos'
|
||||
|
||||
jest.mock('react', () => ({
|
||||
...jest.requireActual('react'),
|
||||
cache: (fn) => fn
|
||||
cache: (fn: any) => fn
|
||||
}))
|
||||
|
||||
describe('getRepos', () => {
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user