import { describe, expect, test } from 'bun:test'; import { findStaleBundledDeps, refreshAndVerifyBundledDeps } from './bundled-deps'; describe('findStaleBundledDeps (ISS-0104)', () => { test('flags a bundled @celilo dep older than the workspace', () => { const mismatches = findStaleBundledDeps( { '@celilo/capabilities': '0.1.8' }, { '@celilo/capabilities': '0.4.1' }, ); expect(mismatches).toEqual([ { pkg: '@celilo/capabilities', bundled: '0.1.8', workspace: '0.4.1' }, ]); }); test('no mismatch when bundled matches workspace', () => { expect( findStaleBundledDeps( { '@celilo/capabilities': '0.4.1', '@celilo/event-bus': '0.1.6' }, { '@celilo/capabilities': '0.4.1', '@celilo/event-bus': '0.1.6' }, ), ).toEqual([]); }); test('ignores workspace packages the module does not bundle', () => { // Module bundles only capabilities; cli-display is a workspace package but // not in this module's closure — must not be flagged. expect( findStaleBundledDeps( { '@celilo/capabilities': '0.4.1' }, { '@celilo/capabilities': '0.4.1', '@celilo/cli-display': '0.1.9' }, ), ).toEqual([]); }); test('flags each stale dep independently', () => { const mismatches = findStaleBundledDeps( { '@celilo/capabilities': '0.1.8', '@celilo/event-bus': '0.1.6' }, { '@celilo/capabilities': '0.4.1', '@celilo/event-bus': '0.1.6' }, ); expect(mismatches).toEqual([ { pkg: '@celilo/capabilities', bundled: '0.1.8', workspace: '0.4.1' }, ]); }); }); describe('refreshAndVerifyBundledDeps (ISS-0104)', () => { test('no-op for a module without scripts/package.json', () => { let installs = 0; const result = refreshAndVerifyBundledDeps('/tmp/does-not-exist-module-xyz', () => { installs++; }); expect(result).toEqual({ refreshed: false, mismatches: [] }); expect(installs).toBe(0); }); });