const assert = require('assert');
const {
  adjacentRect,
  selectEdgeCandidate,
} = require('../app-ui/display-layout');

const local = { x: 0, y: 0, width: 1500, height: 1000 };
const upper = {
  id: 'upper',
  projectedRect: adjacentRect(
    local,
    { x: 0, y: 0, width: 1200, height: 500 },
    'right',
    -250
  ),
};
const lower = {
  id: 'lower',
  projectedRect: adjacentRect(
    local,
    { x: 0, y: 0, width: 1200, height: 500 },
    'right',
    250
  ),
};

assert.strictEqual(upper.projectedRect.y, 0);
assert.strictEqual(lower.projectedRect.y, 500);
assert.strictEqual(
  selectEdgeCandidate([upper, lower], 'right', { x: 1499, y: 100 }).id,
  'upper'
);
assert.strictEqual(
  selectEdgeCandidate([upper, lower], 'right', { x: 1499, y: 900 }).id,
  'lower'
);
assert.strictEqual(
  selectEdgeCandidate([upper, lower], 'right', { x: 1499, y: 499 }).id,
  'upper'
);
assert.strictEqual(
  selectEdgeCandidate([upper, lower], 'right', { x: 1499, y: 500 }).id,
  'lower'
);

console.log('multi-peer edge routing tests passed');
