Skip to content

Commit 093180b

Browse files
committed
Update MetricsBadges.spec.ts
1 parent d5efa72 commit 093180b

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

test/nuxt/components/Package/MetricsBadges.spec.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { afterEach, describe, expect, it, vi } from 'vitest'
2-
import { mountSuspended } from '@nuxt/test-utils/runtime'
2+
import { mockNuxtImport, mountSuspended } from '@nuxt/test-utils/runtime'
33
import type { VueWrapper } from '@vue/test-utils'
44
import { ref } from 'vue'
55
import PackageMetricsBadges from '~/components/Package/MetricsBadges.vue'
@@ -29,6 +29,7 @@ describe('PackageMetricsBadges', () => {
2929
expect(text).toContain('Types')
3030
expect(text).toContain('ESM')
3131
expect(text).toContain('CJS')
32+
expect(text).not.toContain('WASM')
3233
})
3334

3435
it('renders the wasm label', async () => {
@@ -43,5 +44,23 @@ describe('PackageMetricsBadges', () => {
4344

4445
const text = wrapper.text()
4546
expect(text).toContain('WASM')
47+
expect(text).not.toContain('Types')
48+
})
49+
50+
it('does not render the CJS label when no CJS', async () => {
51+
mockUsePackageAnalysis.mockReturnValue({
52+
data: ref({ moduleFormat: 'esm', types: { kind: 'included' } }),
53+
status: ref('success'),
54+
})
55+
56+
wrapper = await mountSuspended(PackageMetricsBadges, {
57+
props: { packageName: '@nuxt/kit' },
58+
})
59+
60+
const text = wrapper.text()
61+
expect(text).toContain('Types')
62+
expect(text).toContain('ESM')
63+
expect(text).not.toContain('CJS')
64+
expect(text).not.toContain('WASM')
4665
})
4766
})

0 commit comments

Comments
 (0)