function checkItemLocation()

in spec/index.js [171:186]


  function checkItemLocation(index, position) {
    const rect = getElementRect(index);
    const { top, bottom } = viewportMetrics().outer;
    const middle = (top + bottom) / 2;

    if (position === 'top') {
      expect(Math.abs(rect.top - top)).to.be.below(1);
    } else if (position === 'bottom') {
      expect(Math.abs(rect.bottom - bottom)).to.be.below(1);
    } else if (position === 'middle') {
      const elMiddle = (rect.top + rect.bottom) / 2;
      expect(Math.abs(elMiddle - middle)).to.be.below(1);
    } else if (_.isNumber(position)) {
      expect(Math.abs(rect.top - (top + position))).to.be.below(1);
    }
  }