github.com/outbrain/consul@v1.4.5/ui-v2/tests/unit/utils/dom/closest-test.js (about) 1 import domClosest from 'consul-ui/utils/dom/closest'; 2 import { module } from 'ember-qunit'; 3 import test from 'ember-sinon-qunit/test-support/test'; 4 import { skip } from 'qunit'; 5 6 module('Unit | Utility | dom/closest'); 7 8 test('it calls Element.closest with the specified selector', function(assert) { 9 const el = { 10 closest: this.stub().returnsArg(0), 11 }; 12 const expected = 'selector'; 13 const actual = domClosest(expected, el); 14 assert.equal(actual, expected); 15 assert.ok(el.closest.calledOnce); 16 }); 17 test("it fails silently/null if calling closest doesn't work/exist", function(assert) { 18 const expected = null; 19 const actual = domClosest('selector', {}); 20 assert.equal(actual, expected); 21 }); 22 skip('polyfill closest');