11import { afterEach , describe , expect , it , vi } from 'vitest'
2- import { mountSuspended } from '@nuxt/test-utils/runtime'
2+ import { mockNuxtImport , mountSuspended } from '@nuxt/test-utils/runtime'
33import type { VueWrapper } from '@vue/test-utils'
44import { ref } from 'vue'
55import 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