import { pendingMigrationNames } from '../migration-drift';

describe('pendingMigrationNames', () => {
    it('returns on-disk migrations that have not been applied, preserving order', () => {
        const onDisk = ['20260101_a', '20260102_b', '20260103_c'];
        const applied = ['20260101_a', '20260102_b'];
        expect(pendingMigrationNames(onDisk, applied)).toEqual(['20260103_c']);
    });

    it('returns empty when every on-disk migration is applied', () => {
        expect(pendingMigrationNames(['a', 'b'], ['a', 'b'])).toEqual([]);
    });

    it('ignores applied rows that are not on disk (already-applied, later removed)', () => {
        expect(pendingMigrationNames(['b'], ['a', 'b'])).toEqual([]);
    });

    it('treats every on-disk migration as pending when none are applied (fresh/un-baselined DB)', () => {
        expect(pendingMigrationNames(['a', 'b'], [])).toEqual(['a', 'b']);
    });
});
