jest.dontMock('../DOMUtil');

var DOMUtil = require('../DOMUtil');

describe('DOMUtil', function () {

  describe('#closest', function () {

    it('should should return the parent element when provided a selector and ' +
      'element where the element is a child of the selection', function () {
      var el = {
        parentElement: {
          id: 'something-fake',
          matches: function () {
            return true;
          }
        },
        matches: function () {
          return false;
        }
      };
      var match = DOMUtil.closest(el, '.fake-selector');

      expect(match.id).toEqual('something-fake');
    });

    it('should should return null when provided a selector and element where ' +
      'the element is not a child of the selection', function () {
      var el = {
        parentElement: null,
        matches: function () {
          return true;
        }
      };
      var match = DOMUtil.closest(el, '.fake-selector');

      expect(match).toEqual(null);
    });

    it('should should return the provided element when the provided element' +
      'matches the selector AND has a parent element', function () {
      var el = {
        parentElement: {
          id: 'something-fake',
          matches: function () {
            return false;
          }
        },
        id: 'child-element',
        matches: function () {
          return true;
        }
      };
      var match = DOMUtil.closest(el, '.fake-selector');

      expect(match.id).toEqual('child-element');
    });

  });

});

@@ -23,16 +23,207 @@
 til');%0A%0A
+/* eslint-disable no-unused-vars */%0Avar React = require('react');%0A/* eslint-enable no-unused-vars */%0Avar TestUtils = require('react-addons-test-utils');%0Avar ReactDOM = require('react-dom');%0A%0A
 var DOMU
@@ -1727,12 +1727,782 @@
 %0A  %7D);%0A%0A
+  describe('#getNodeClearance', function () %7B%0A%0A    beforeEach(function () %7B%0A      DOMUtil.getViewportHeight = function () %7B%0A        return 600;%0A      %7D;%0A%0A      DOMUtil.getViewportWidth = function () %7B%0A        return 600;%0A      %7D;%0A    %7D);%0A%0A    it('should return the element%5C's distance from all edges', function () %7B%0A      let node = %7B%0A        getBoundingClientRect: function () %7B%0A          return %7B%0A            bottom: 200,%0A            left: 100,%0A            right: 200,%0A            top: 100%0A          %7D;%0A        %7D%0A      %7D;%0A%0A      let clearance = DOMUtil.getNodeClearance(node);%0A%0A      expect(clearance.bottom).toEqual(400);%0A      expect(clearance.left).toEqual(100);%0A      expect(clearance.right).toEqual(400);%0A      expect(clearance.top).toEqual(100);%0A    %7D);%0A%0A  %7D);%0A%0A
 %7D);%0A

Add tests