mirror of
https://github.com/kremalicious/portfolio.git
synced 2024-12-22 09:13:19 +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
|
Contrast
|
||||||
}
|
}
|
||||||
|
|
||||||
const IconMapped = components[name]
|
const IconMapped = components[name as keyof typeof components]
|
||||||
|
|
||||||
return IconMapped ? (
|
return IconMapped ? (
|
||||||
<IconMapped className={`${styles.icon} ${styles[name]}`} {...props} />
|
<IconMapped className={`${styles.icon} ${styles[name]}`} {...props} />
|
||||||
|
@ -18,7 +18,7 @@ function Animation({ children }: { children: React.ReactNode }) {
|
|||||||
aria-label="Location"
|
aria-label="Location"
|
||||||
variants={fadeIn}
|
variants={fadeIn}
|
||||||
className={styles.location}
|
className={styles.location}
|
||||||
{...getAnimationProps(shouldReduceMotion)}
|
{...getAnimationProps(shouldReduceMotion || false)}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</m.section>
|
</m.section>
|
||||||
|
@ -18,9 +18,13 @@ export default function ProjectNav({ projects, currentSlug }: Props) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function scrollToCurrent() {
|
function scrollToCurrent() {
|
||||||
|
if (!scrollContainer.current || !currentItem.current) return
|
||||||
|
|
||||||
const activeItem = currentItem.current
|
const activeItem = currentItem.current
|
||||||
const scrollRect = scrollContainer.current?.getBoundingClientRect()
|
const scrollRect = scrollContainer.current.getBoundingClientRect()
|
||||||
const activeRect = activeItem && activeItem.getBoundingClientRect()
|
const activeRect = activeItem && activeItem.getBoundingClientRect()
|
||||||
|
if (!activeItem || !scrollRect || !activeRect) return
|
||||||
|
|
||||||
const newScrollLeftPosition =
|
const newScrollLeftPosition =
|
||||||
activeRect &&
|
activeRect &&
|
||||||
activeRect.left -
|
activeRect.left -
|
||||||
|
@ -23,7 +23,7 @@ describe('imageToDataUrl', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should convert image to data URL', async () => {
|
it('should convert image to data URL', async () => {
|
||||||
function MockFileReader() {
|
function MockFileReader(this: any) {
|
||||||
this.readAsDataURL = function () {
|
this.readAsDataURL = function () {
|
||||||
this.result = 'data:image/png;base64,...'
|
this.result = 'data:image/png;base64,...'
|
||||||
setTimeout(() => this.onload(), 0)
|
setTimeout(() => this.onload(), 0)
|
||||||
@ -33,11 +33,12 @@ describe('imageToDataUrl', () => {
|
|||||||
window.FileReader = MockFileReader as any
|
window.FileReader = MockFileReader as any
|
||||||
|
|
||||||
const dataUrl = await imageToDataUrl(dummyPath)
|
const dataUrl = await imageToDataUrl(dummyPath)
|
||||||
|
|
||||||
expect(dataUrl).toBe('data:image/png;base64,...')
|
expect(dataUrl).toBe('data:image/png;base64,...')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should handle errors in readAsDataURL', async () => {
|
it('should handle errors in readAsDataURL', async () => {
|
||||||
function MockFileReader() {
|
function MockFileReader(this: FileReader) {
|
||||||
this.readAsDataURL = function () {
|
this.readAsDataURL = function () {
|
||||||
throw new Error('Mock error')
|
throw new Error('Mock error')
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import { getRepos } from './getRepos'
|
|||||||
|
|
||||||
jest.mock('react', () => ({
|
jest.mock('react', () => ({
|
||||||
...jest.requireActual('react'),
|
...jest.requireActual('react'),
|
||||||
cache: (fn) => fn
|
cache: (fn: any) => fn
|
||||||
}))
|
}))
|
||||||
|
|
||||||
describe('getRepos', () => {
|
describe('getRepos', () => {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strict": false, // TODO: Change to strict: true
|
"strict": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
Loading…
Reference in New Issue
Block a user