diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-02-25 15:07:00 -0500 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 12:55:19 +0200 |
commit | eb70e6e3d0bff11c25f14b1196025791bf2308fb (patch) | |
tree | 5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/components/microformats/test/module-tests/domutils-test.js | |
parent | 32ead795290b3399d56b4708fc75b77d296f6a1a (diff) | |
download | UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip |
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/microformats/test/module-tests/domutils-test.js')
-rw-r--r-- | toolkit/components/microformats/test/module-tests/domutils-test.js | 206 |
1 files changed, 0 insertions, 206 deletions
diff --git a/toolkit/components/microformats/test/module-tests/domutils-test.js b/toolkit/components/microformats/test/module-tests/domutils-test.js deleted file mode 100644 index 5d3f036a9..000000000 --- a/toolkit/components/microformats/test/module-tests/domutils-test.js +++ /dev/null @@ -1,206 +0,0 @@ -/* -Unit test for domutils -*/ - -assert = chai.assert; - - -// Tests the private Modules.domUtils object -// Modules.domUtils is unit tested as it has an interface access by other modules - - -describe('Modules.domutils', function() { - - - it('ownerDocument', function(){ - var node = document.createElement('div'); - assert.equal( Modules.domUtils.ownerDocument( node ).nodeType, 9); - }); - - - it('innerHTML', function(){ - var html = '<a href="http://glennjones.net">Glenn Jones</a>', - node = document.createElement('div'); - - node.innerHTML = html; - assert.equal( Modules.domUtils.innerHTML( node ), html ); - }); - - - it('hasAttribute', function(){ - var node = document.createElement('a'); - - node.href = 'http://glennjones.net'; - assert.isTrue( Modules.domUtils.hasAttribute( node, 'href' ) ); - assert.isFalse( Modules.domUtils.hasAttribute( node, 'class' ) ); - }); - - - it('hasAttributeValue', function(){ - var node = document.createElement('a'); - - node.href = 'http://glennjones.net'; - assert.isTrue( Modules.domUtils.hasAttributeValue( node, 'href', 'http://glennjones.net' ) ); - assert.isFalse( Modules.domUtils.hasAttributeValue( node, 'href', 'http://example.net' ) ); - assert.isFalse( Modules.domUtils.hasAttributeValue( node, 'class', 'test' ) ); - }); - - - it('getAttribute', function(){ - var node = document.createElement('a'); - - node.href = 'http://glennjones.net'; - assert.equal( Modules.domUtils.getAttribute( node, 'href' ), 'http://glennjones.net' ); - }); - - - it('setAttribute', function(){ - var node = document.createElement('a'); - - Modules.domUtils.setAttribute(node, 'href', 'http://glennjones.net') - assert.equal( Modules.domUtils.getAttribute( node, 'href' ), 'http://glennjones.net' ); - }); - - - it('removeAttribute', function(){ - var node = document.createElement('a'); - - node.href = 'http://glennjones.net'; - Modules.domUtils.removeAttribute(node, 'href') - assert.isFalse( Modules.domUtils.hasAttribute( node, 'href' ) ); - }); - - - it('getAttributeList', function(){ - var node = document.createElement('a'); - - node.rel = 'next'; - assert.deepEqual( Modules.domUtils.getAttributeList( node, 'rel'), ['next'] ); - node.rel = 'next bookmark'; - assert.deepEqual( Modules.domUtils.getAttributeList( node, 'rel'), ['next','bookmark'] ); - }); - - - it('hasAttributeValue', function(){ - var node = document.createElement('a'); - - node.href = 'http://glennjones.net'; - node.rel = 'next bookmark'; - assert.isTrue( Modules.domUtils.hasAttributeValue( node, 'href', 'http://glennjones.net' ) ); - assert.isFalse( Modules.domUtils.hasAttributeValue( node, 'href', 'http://codebits.glennjones.net' ) ); - assert.isFalse( Modules.domUtils.hasAttributeValue( node, 'class', 'p-name' ) ); - assert.isTrue( Modules.domUtils.hasAttributeValue( node, 'rel', 'bookmark' ) ); - assert.isFalse( Modules.domUtils.hasAttributeValue( node, 'rel', 'previous' ) ); - }); - - - it('getNodesByAttribute', function(){ - var node = document.createElement('ul'); - node.innerHTML = '<li class="h-card">one</li><li>two</li><li class="h-card">three</li>'; - - assert.equal( Modules.domUtils.getNodesByAttribute( node, 'class' ).length, 2 ); - assert.equal( Modules.domUtils.getNodesByAttribute( node, 'href' ).length, 0 ); - }); - - - it('getNodesByAttributeValue', function(){ - var node = document.createElement('ul'); - node.innerHTML = '<li class="h-card">one</li><li>two</li><li class="h-card">three</li><li class="p-name">four</li>'; - - assert.equal( Modules.domUtils.getNodesByAttributeValue( node, 'class', 'h-card' ).length, 2 ); - assert.equal( Modules.domUtils.getNodesByAttributeValue( node, 'class', 'p-name' ).length, 1 ); - assert.equal( Modules.domUtils.getNodesByAttributeValue( node, 'class', 'u-url' ).length, 0 ); - }); - - - it('getAttrValFromTagList', function(){ - var node = document.createElement('a'); - - node.href = 'http://glennjones.net'; - - assert.equal( Modules.domUtils.getAttrValFromTagList( node, ['a','area'], 'href' ), 'http://glennjones.net' ); - assert.equal( Modules.domUtils.getAttrValFromTagList( node, ['a','area'], 'class' ), null ); - assert.equal( Modules.domUtils.getAttrValFromTagList( node, ['p'], 'href' ), null ); - }); - - - it('getSingleDescendant', function(){ - var html = '<a class="u-url" href="http://glennjones.net">Glenn Jones</a>', - node = document.createElement('div'); - - node.innerHTML = html, - - // one instance of a element - assert.equal( Modules.domUtils.getSingleDescendant( node ).outerHTML, html ); - - // two instances of a element - node.appendChild(document.createElement('a')); - assert.equal( Modules.domUtils.getSingleDescendant( node ), null ); - - }); - - - it('getSingleDescendantOfType', function(){ - var html = '<a class="u-url" href="http://glennjones.net">Glenn Jones</a>', - node = document.createElement('div'); - - node.innerHTML = html, - - // one instance of a element - assert.equal( Modules.domUtils.getSingleDescendantOfType( node, ['a', 'link']).outerHTML, html ); - assert.equal( Modules.domUtils.getSingleDescendantOfType( node, ['img','area']), null ); - - node.appendChild(document.createElement('p')); - assert.equal( Modules.domUtils.getSingleDescendantOfType( node, ['a', 'link']).outerHTML, html ); - - // two instances of a element - node.appendChild(document.createElement('a')); - assert.equal( Modules.domUtils.getSingleDescendantOfType( node, ['a', 'link']), null ); - - }); - - - it('appendChild', function(){ - var node = document.createElement('div'), - child = document.createElement('a'); - - Modules.domUtils.appendChild( node, child ); - assert.equal( node.innerHTML, '<a></a>' ); - }); - - - it('removeChild', function(){ - var node = document.createElement('div'), - child = document.createElement('a'); - - node.appendChild(child) - - assert.equal( node.innerHTML, '<a></a>' ); - Modules.domUtils.removeChild( child ); - assert.equal( node.innerHTML, '' ); - }); - - - it('clone', function(){ - var node = document.createElement('div'); - - node.innerHTML = 'text content'; - assert.equal( Modules.domUtils.clone( node ).outerHTML, '<div>text content</div>' ); - }); - - - it('getElementText', function(){ - assert.equal( Modules.domUtils.getElementText( {} ), '' ); - }); - - - it('getNodePath', function(){ - var node = document.createElement('ul'); - node.innerHTML = '<div><ul><li class="h-card">one</li><li>two</li><li class="h-card">three</li><li class="p-name">four</li></ul></div>'; - var child = node.querySelector('.p-name'); - - assert.deepEqual( Modules.domUtils.getNodePath( child ), [0,0,3] ); - }); - - -}); |