github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/ui-v2/tests/unit/utils/dom/sibling-test.js (about) 1 import domSibling from 'consul-ui/utils/dom/sibling'; 2 import { module, test } from 'qunit'; 3 4 module('Unit | Utility | dom/sibling'); 5 6 test('it returns the next sibling if it matches the requested nodeName', function(assert) { 7 const expected = { 8 nodeType: 1, 9 nodeName: 'H1', 10 }; 11 const actual = domSibling( 12 { 13 nextSibling: expected, 14 }, 15 'h1' 16 ); 17 assert.deepEqual(actual, expected); 18 }); 19 test('it returns the next sibling from a list of nodes if it matches the requested nodeName', function(assert) { 20 const expected = { 21 nodeType: 1, 22 nodeName: 'H1', 23 }; 24 const nodes = { 25 nodeType: 3, 26 nodeName: '#text', 27 nextSibling: { 28 nodeType: 4, 29 nodeName: '#cdata-section', 30 nextSibling: expected, 31 }, 32 }; 33 const actual = domSibling( 34 { 35 nextSibling: nodes, 36 }, 37 'h1' 38 ); 39 assert.deepEqual(actual, expected); 40 }); 41 test("it returns the null from a list of nodes if it can't match", function(assert) { 42 let expected; 43 const nodes = { 44 nodeType: 3, 45 nodeName: '#text', 46 nextSibling: { 47 nodeType: 4, 48 nodeName: '#cdata-section', 49 nextSibling: { 50 nodeType: 1, 51 nodeName: 'p', 52 }, 53 }, 54 }; 55 const actual = domSibling( 56 { 57 nextSibling: nodes, 58 }, 59 'h1' 60 ); 61 assert.deepEqual(actual, expected); 62 });