const test = require('node:test');
const assert = require('node:assert/strict');

const MeasurementBuilder = require('../src/measurements/MeasurementBuilder.js');

test('builder requires mandatory fields', () => {
  assert.throws(() => new MeasurementBuilder().build(), /Measurement type is required/);
  assert.throws(() => new MeasurementBuilder().setType('flow').build(), /Measurement variant is required/);
  assert.throws(
    () => new MeasurementBuilder().setType('flow').setVariant('measured').build(),
    /Measurement position is required/
  );
});

test('builder creates measurement with provided config', () => {
  const measurement = new MeasurementBuilder()
    .setType('flow')
    .setVariant('measured')
    .setPosition('upstream')
    .setWindowSize(25)
    .setDistance(3.2)
    .build();

  assert.equal(measurement.type, 'flow');
  assert.equal(measurement.variant, 'measured');
  assert.equal(measurement.position, 'upstream');
  assert.equal(measurement.windowSize, 25);
  assert.equal(measurement.distance, 3.2);
});
