let assignments = require('./assignments')

describe('assignments', () => {
  test('assigns asset to employee correctly', () => {
    const body = {
      asset_id: 1,
      employee_id: 1,
      department: 'IT',
      location: 'Headquarters',
      notes: 'Assigned for testing'
    };
    const userId = 1;
    const assignment = assignments.assignAsset(body, userId);
    expect(assignment).toBeDefined();
    expect(assignment.asset_id).toBe(body.asset_id);
    expect(assignment.employee_id).toBe(body.employee_id);
    expect(assignment.department).toBe(body.department);
    expect(assignment.location).toBe(body.location);
    expect(assignment.status).toBe('assigned');
  });

  test('releases asset assignment correctly', () => {
    const body = {
      release_reason: 'No longer needed',
      notes: 'Released after testing'
    };
    const userId = 1;
    const assignment = assignments.assignAsset({
      asset_id: 1,
      employee_id: 1,
      department: 'IT',
      location: 'Headquarters'
    }, userId);
    const released = assignments.releaseAssignment(assignment.id, body, userId);
    expect(released).toBeDefined();
    expect(released.id).toBe(assignment.id);
    expect(released.status).toBe('released');
    expect(released.release_reason).toBe(body.release_reason);
    expect(released.notes).toBe(body.notes);
  });
});
