Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ export default defineNuxtConfig({
base: './.cache/atproto-oauth/session',
},
},
typescript: {
tsConfig: {
include: ['../test/unit/server/**/*.ts'],
},
},
},

fonts: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { describe, expect, it } from 'vitest'
import {
hasSearchOperators,
parseSearchOperators,
} from '../../app/composables/useStructuredFilters'
import { hasSearchOperators, parseSearchOperators } from '~/composables/useStructuredFilters'

describe('parseSearchOperators', () => {
describe('basic operator parsing', () => {
Expand Down
7 changes: 4 additions & 3 deletions test/unit/server/utils/dependency-analysis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { describe, expect, it, vi, beforeEach } from 'vitest'

// Mock Nitro globals before importing the module
vi.stubGlobal('defineCachedFunction', (fn: Function) => fn)
vi.stubGlobal('$fetch', vi.fn())
const $fetchMock = vi.fn()
vi.stubGlobal('$fetch', $fetchMock)

// Import module under test
const { analyzeDependencyTree } = await import('../../../../server/utils/dependency-analysis')
Expand All @@ -26,7 +27,7 @@ function mockOsvApi(
batchResults: Array<{ vulns?: Array<{ id: string; modified: string }> }>,
detailResults: Map<string, { vulns?: Array<Record<string, unknown>> }> = new Map(),
) {
vi.mocked($fetch).mockImplementation(async (url: string, options?: { body?: unknown }) => {
$fetchMock.mockImplementation(async (url: string, options?: { body?: unknown }) => {
if (url === 'https://api.osv.dev/v1/querybatch') {
return { results: batchResults }
}
Expand Down Expand Up @@ -102,7 +103,7 @@ describe('dependency-analysis', () => {
vi.mocked(resolveDependencyTree).mockResolvedValue(mockResolved)

// Batch query fails entirely
vi.mocked($fetch).mockRejectedValue(new Error('OSV API error'))
$fetchMock.mockRejectedValue(new Error('OSV API error'))

const result = await analyzeDependencyTree('test-pkg', '1.0.0')

Expand Down
14 changes: 7 additions & 7 deletions test/unit/server/utils/readme.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Playground Link Extraction', () => {
const result = await renderReadmeHtml(markdown, 'test-pkg')

expect(result.playgroundLinks).toHaveLength(1)
expect(result.playgroundLinks[0].provider).toBe('codesandbox')
expect(result.playgroundLinks[0]!.provider).toBe('codesandbox')
})
})

Expand All @@ -56,21 +56,21 @@ describe('Playground Link Extraction', () => {
const markdown = `[Pen](https://codepen.io/user/pen/abc123)`
const result = await renderReadmeHtml(markdown, 'test-pkg')

expect(result.playgroundLinks[0].provider).toBe('codepen')
expect(result.playgroundLinks[0]!.provider).toBe('codepen')
})

it('extracts Replit links', async () => {
const markdown = `[Repl](https://replit.com/@user/project)`
const result = await renderReadmeHtml(markdown, 'test-pkg')

expect(result.playgroundLinks[0].provider).toBe('replit')
expect(result.playgroundLinks[0]!.provider).toBe('replit')
})

it('extracts Gitpod links', async () => {
const markdown = `[Open in Gitpod](https://gitpod.io/#https://github.com/user/repo)`
const result = await renderReadmeHtml(markdown, 'test-pkg')

expect(result.playgroundLinks[0].provider).toBe('gitpod')
expect(result.playgroundLinks[0]!.provider).toBe('gitpod')
})
})

Expand All @@ -83,8 +83,8 @@ describe('Playground Link Extraction', () => {
const result = await renderReadmeHtml(markdown, 'test-pkg')

expect(result.playgroundLinks).toHaveLength(2)
expect(result.playgroundLinks[0].provider).toBe('stackblitz')
expect(result.playgroundLinks[1].provider).toBe('codesandbox')
expect(result.playgroundLinks[0]!.provider).toBe('stackblitz')
expect(result.playgroundLinks[1]!.provider).toBe('codesandbox')
})

it('deduplicates same URL', async () => {
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('Playground Link Extraction', () => {
const result = await renderReadmeHtml(markdown, 'test-pkg')

expect(result.playgroundLinks).toHaveLength(1)
expect(result.playgroundLinks[0].provider).toBe('stackblitz')
expect(result.playgroundLinks[0]!.provider).toBe('stackblitz')
})
})
})
Loading