import { readFileSync } from 'node:fs' import { dirname, resolve } from 'node:path' import { fileURLToPath } from 'node:url' import { describe, expect, it } from 'vitest' const __dirname = dirname(fileURLToPath(import.meta.url)) const pkg = JSON.parse( readFileSync(resolve(__dirname, '..', 'package.json'), 'utf8') ) describe('package metadata', () => { it('exposes dual-build entrypoints for easy installation', () => { expect(pkg.main).toBe('./dist/index.js') expect(pkg.module).toBe('./dist/index.js') expect(pkg.types).toBe('./dist/index.d.ts') expect(pkg.exports?.['.']?.import).toBe('./dist/index.js') expect(pkg.exports?.['.']?.require).toBe('./dist/index.cjs') expect(pkg.exports?.['.']?.types).toBe('./dist/index.d.ts') }) it('ships distributable files and documentation', () => { expect(pkg.files).toEqual( expect.arrayContaining(['dist', 'README.md', 'LICENSE']) ) }) it('includes the CLI entrypoint', () => { expect(pkg.bin?.typedfetch).toBe('./dist/cli.js') }) it('is versioned for publishing', () => { expect(pkg.version).not.toBe('0.0.0') }) })