import assert from 'node:assert/strict';
import test from 'node:test';
import { flattenProjects, flattenVersions } from './derive';

const overview = [{
  id: 'product-1',
  name: 'Product',
  projects: [{
    id: 'project-1',
    name: 'Project',
    description: '',
    createdAt: '2026-07-02T00:00:00.000Z',
  }],
  versions: [{
    id: 'version-1',
    name: 'ProjectV1.0',
    releaseDate: null,
    createdAt: '2026-07-02T00:00:00.000Z',
  }],
}];

test('flattenVersions defaults missing version status to planned', () => {
  const [version] = flattenVersions(overview);

  assert.equal(version.status, 'planned');
});

test('flattenProjects defaults nested missing version status to planned', () => {
  const [project] = flattenProjects(overview);

  assert.equal(project.versions[0].status, 'planned');
});
