Skip to content

Commit

Permalink
fix mock
Browse files Browse the repository at this point in the history
  • Loading branch information
severo committed Nov 15, 2024
1 parent 872b33c commit 92920c6
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/components/test/Folder.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ import React from 'react'
import { describe, expect, it, vi } from 'vitest'
import Folder from '../src/Folder.js'

vi.mock('../../src/lib/files.js', () => ({
listFiles: vi.fn(),
getFileDate: vi.fn((f: FileMetadata) => f.lastModified),
getFileDateShort: vi.fn((f: FileMetadata) => f.lastModified),
getFileSize: vi.fn((f: FileMetadata) => f.fileSize),
}))
vi.mock('@hyparam/utils', async (importOriginal) => {
const actual = await importOriginal()
if (typeof actual === 'object') {
return {
...actual,
// your mocked methods
listFiles: vi.fn(),
getFileDate: vi.fn((f: FileMetadata) => f.lastModified),
getFileDateShort: vi.fn((f: FileMetadata) => f.lastModified),
getFileSize: vi.fn((f: FileMetadata) => f.fileSize),
}
}
})

const mockFiles: FileMetadata[] = [
{ key: 'folder1/', lastModified: '2023-01-01T00:00:00Z' },
Expand Down

0 comments on commit 92920c6

Please sign in to comment.