Skip to content

Commit a5f81bf

Browse files
committed
test: update tests
1 parent 5e2ee11 commit a5f81bf

2 files changed

Lines changed: 12 additions & 23 deletions

File tree

test/nuxt/a11y.spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,20 +503,18 @@ describe('component accessibility audits', () => {
503503

504504
describe('PackageVersions', () => {
505505
it('should have no accessibility violations', async () => {
506-
// Minimal mock data satisfying PackumentVersion type
506+
// Minimal mock data satisfying SlimVersion type
507507
const mockVersion = {
508-
_id: 'vue@3.5.0',
509-
_npmVersion: '10.0.0',
510-
name: 'vue',
511508
version: '3.5.0',
512-
dist: { tarball: '', shasum: '', signatures: [] },
509+
deprecated: undefined,
510+
tags: undefined,
513511
}
514512
const component = await mountSuspended(PackageVersions, {
515513
props: {
516514
packageName: 'vue',
517515
versions: {
518516
'3.5.0': mockVersion,
519-
'3.4.0': { ...mockVersion, _id: 'vue@3.4.0', version: '3.4.0' },
517+
'3.4.0': { ...mockVersion, version: '3.4.0' },
520518
},
521519
distTags: {
522520
latest: '3.5.0',

test/nuxt/components/PackageVersions.spec.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, expect, it, vi, beforeEach } from 'vitest'
22
import { mountSuspended } from '@nuxt/test-utils/runtime'
33
import PackageVersions from '~/components/Package/Versions.vue'
4-
import type { PackumentVersion } from '#shared/types'
4+
import type { SlimVersion } from '#shared/types'
55

66
// Mock the fetchAllPackageVersions function
77
const mockFetchAllPackageVersions = vi.fn()
@@ -10,30 +10,21 @@ vi.mock('~/composables/useNpmRegistry', () => ({
1010
}))
1111

1212
/**
13-
* Helper to create a minimal PackumentVersion for testing
13+
* Helper to create a minimal SlimVersion for testing
1414
*/
1515
function createVersion(
1616
version: string,
1717
options: {
1818
deprecated?: string
1919
hasProvenance?: boolean
2020
} = {},
21-
): PackumentVersion {
22-
const dist: Record<string, unknown> = {
23-
tarball: `https://registry.npmjs.org/test-package/-/test-package-${version}.tgz`,
24-
shasum: 'abc123',
25-
}
26-
if (options.hasProvenance) {
27-
dist.attestations = { url: 'https://example.com', provenance: { predicateType: 'test' } }
28-
}
21+
): SlimVersion {
2922
return {
30-
_id: `test-package@${version}`,
31-
_npmVersion: '10.0.0',
32-
name: 'test-package',
3323
version,
34-
dist,
3524
deprecated: options.deprecated,
36-
} as unknown as PackumentVersion
25+
tags: undefined,
26+
...(options.hasProvenance ? { hasProvenance: true } : {}),
27+
} as SlimVersion
3728
}
3829

3930
describe('PackageVersions', () => {
@@ -459,7 +450,7 @@ describe('PackageVersions', () => {
459450

460451
it('shows count of hidden tagged versions', async () => {
461452
// Create more than MAX_VISIBLE_TAGS (10) dist-tags
462-
const versions: Record<string, PackumentVersion> = {}
453+
const versions: Record<string, SlimVersion> = {}
463454
const distTags: Record<string, string> = {}
464455
const time: Record<string, string> = {}
465456

@@ -551,7 +542,7 @@ describe('PackageVersions', () => {
551542
describe('MAX_VISIBLE_TAGS limit', () => {
552543
it('limits visible tag rows to 10', async () => {
553544
// Create 15 dist-tags
554-
const versions: Record<string, PackumentVersion> = {}
545+
const versions: Record<string, SlimVersion> = {}
555546
const distTags: Record<string, string> = {}
556547
const time: Record<string, string> = {}
557548

0 commit comments

Comments
 (0)