diff options
Diffstat (limited to 'toolkit/components/microformats/test/interface-tests')
7 files changed, 0 insertions, 1369 deletions
diff --git a/toolkit/components/microformats/test/interface-tests/count-test.js b/toolkit/components/microformats/test/interface-tests/count-test.js deleted file mode 100644 index baac56c2b..000000000 --- a/toolkit/components/microformats/test/interface-tests/count-test.js +++ /dev/null @@ -1,107 +0,0 @@ -/* -Unit test for count -*/ - -assert = chai.assert; - - -describe('Microformat.count', function() { - - it('count', function(){ - - var doc, - node, - result; - - var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a><a class="h-card" href="http://janedoe.net"><span class="p-name">Jane</span></a><a class="h-event" href="http://janedoe.net"><span class="p-name">Event</span><span class="dt-start">2015-07-01</span></a>'; - - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = html; - doc.body.appendChild(node); - - options ={ - 'node': node, - }; - - result = Microformats.count(options); - assert.deepEqual( result, {'h-event': 1,'h-card': 2} ); - - }); - - - it('count rels', function(){ - - var doc, - node, - result; - - var html = '<link href="http://glennjones.net/notes/atom" rel="notes alternate" title="Notes" type="application/atom+xml" /><a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a><a class="h-card" href="http://janedoe.net"><span class="p-name">Jane</span></a><a class="h-event" href="http://janedoe.net"><span class="p-name">Event</span><span class="dt-start">2015-07-01</span></a>'; - - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = html; - doc.body.appendChild(node); - - options ={ - 'node': node, - }; - - result = Microformats.count(options); - assert.deepEqual( result, {'h-event': 1,'h-card': 2, 'rels': 1} ); - - }); - - - it('count - no results', function(){ - - var doc, - node, - result; - - var html = '<span class="p-name">Jane</span>'; - - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = html; - doc.body.appendChild(node); - - options ={ - 'node': node, - }; - - result = Microformats.count(options); - assert.deepEqual( result, {} ); - - }); - - - - it('count - no options', function(){ - - var result; - - result = Microformats.count({}); - assert.deepEqual( result, {} ); - - }); - - - it('count - options.html', function(){ - - var options = {}, - result; - - options.html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a><a class="h-card" href="http://janedoe.net"><span class="p-name">Jane</span></a><a class="h-event" href="http://janedoe.net"><span class="p-name">Event</span><span class="dt-start">2015-07-01</span></a>'; - - result = Microformats.count(options); - assert.deepEqual( result, {'h-event': 1,'h-card': 2} ); - - }); - - - - }); diff --git a/toolkit/components/microformats/test/interface-tests/experimental-test.js b/toolkit/components/microformats/test/interface-tests/experimental-test.js deleted file mode 100644 index 4d32b83c0..000000000 --- a/toolkit/components/microformats/test/interface-tests/experimental-test.js +++ /dev/null @@ -1,37 +0,0 @@ -/* -Unit test for get -*/ - -assert = chai.assert; - - -describe('experimental', function() { - - it('h-geo - geo data writen as lat;lon', function(){ - - var expected = { - 'items': [{ - 'type': ['h-geo'], - 'properties': { - 'name': ['30.267991;-97.739568'], - 'latitude': [30.267991], - 'longitude': [-97.739568] - } - }], - 'rels': {}, - 'rel-urls': {} - }, - options = { - 'html': '<div class="h-geo">30.267991;-97.739568</div>', - 'baseUrl': 'http://example.com', - 'dateFormat': 'html5', - 'parseLatLonGeo': true - }; - - var result = Microformats.get(options); - assert.deepEqual( result, expected ); - - }); - - -}); diff --git a/toolkit/components/microformats/test/interface-tests/get-test.js b/toolkit/components/microformats/test/interface-tests/get-test.js deleted file mode 100644 index 098ff4e3d..000000000 --- a/toolkit/components/microformats/test/interface-tests/get-test.js +++ /dev/null @@ -1,605 +0,0 @@ -/* -Unit test for get -*/ - -assert = chai.assert; - - -describe('Microformat.get', function() { - - - var expected = { - 'items': [{ - 'type': ['h-card'], - 'properties': { - 'name': ['Glenn Jones'], - 'url': ['http://glennjones.net'] - } - }], - 'rels': { - 'bookmark': ['http://glennjones.net'], - 'alternate': ['http://example.com/fr'], - 'home': ['http://example.com/fr'] - }, - 'rel-urls': { - 'http://glennjones.net': { - 'text': 'Glenn Jones', - 'rels': ['bookmark'] - }, - 'http://example.com/fr': { - 'media': 'handheld', - 'hreflang': 'fr', - 'text': 'French mobile homepage', - 'rels': ['alternate', 'home'] - } - } - }, - html = '<div class="h-card"><a class="p-name u-url" rel="bookmark" href="http://glennjones.net">Glenn Jones</a></div><a rel="alternate home" href="http://example.com/fr" media="handheld" hreflang="fr">French mobile homepage</a>'; - - - - - - it('get - no options.node parse this document', function(){ - var result; - - result = Microformats.get({}); - assert.deepEqual( result.items, [] ); - }); - - - it('get - standard', function(){ - - var doc, - node, - options, - result; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = html; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'baseUrl': 'http://example.com', - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.deepEqual( result, expected ); - - }); - - - it('get - doc pass to node', function(){ - - var doc, - node, - options, - result; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = html; - doc.body.appendChild(node); - - options ={ - 'node': doc, - 'baseUrl': 'http://example.com', - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.deepEqual( result, expected ); - - }); - - - it('get - pass base tag', function(){ - - var doc, - node, - options, - result; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = html + '<base href="http://example.com">'; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.deepEqual( result, expected ); - - }); - - - it('get - pass no document', function(){ - - var doc, - node, - options, - parser, - result; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = html + '<base href="http://example.com">'; - doc.body.appendChild(node); - - options ={ - 'node': doc, - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.deepEqual( result, expected ); - - }); - - - it('get - textFormat: normalised', function(){ - - var doc, - node, - options, - result; - - var altHTML = '<a class="h-card" href="http://glennjones.net">\n'; - altHTML += ' <span class="p-given-name">Glenn</span>\n'; - altHTML += ' <span class="p-family-name">Jones</span>\n'; - altHTML += '</a>\n'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'textFormat': 'normalised', - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.equal( result.items[0].properties.name[0], 'Glenn Jones' ); - - }); - - - it('get - textFormat: whitespace', function(){ - - var doc, - node, - options, - parser, - result; - - var altHTML = '<a class="h-card" href="http://glennjones.net">\n'; - altHTML += ' <span class="p-given-name">Glenn</span>\n'; - altHTML += ' <span class="p-family-name">Jones</span>\n'; - altHTML += '</a>\n'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'textFormat': 'whitespace', - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.equal( result.items[0].properties.name[0], '\n Glenn\n Jones\n' ); - - }); - - - - it('get - textFormat: whitespacetrimmed', function(){ - - var doc, - node, - options, - result; - - var altHTML = '<a class="h-card" href="http://glennjones.net">\n'; - altHTML += ' <span class="p-given-name">Glenn</span>\n'; - altHTML += ' <span class="p-family-name">Jones</span>\n'; - altHTML += '</a>\n'; - - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'textFormat': 'whitespacetrimmed', - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.equal( result.items[0].properties.name[0], 'Glenn\n Jones' ); - - }); - - - it('get - dateFormat: auto', function(){ - - var doc, - node, - options, - result; - - var altHTML = '<div class="h-event"><span class="p-name">Pub</span><span class="dt-start">2015-07-01t17:30z</span></div>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'dateFormat': 'auto' - }; - - result = Microformats.get(options); - assert.equal( result.items[0].properties.start[0], '2015-07-01t17:30z' ); - - }); - - - it('get - dateFormat: w3c', function(){ - - var doc, - node, - options, - result; - - var altHTML = '<div class="h-event"><span class="p-name">Pub</span><span class="dt-start">2015-07-01t17:30z</span></div>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'dateFormat': 'w3c' - }; - - result = Microformats.get(options); - assert.equal( result.items[0].properties.start[0], '2015-07-01T17:30Z' ); - - }); - - - it('get - dateFormat: html5', function(){ - - var doc, - node, - options, - result; - - var altHTML = '<div class="h-event"><span class="p-name">Pub</span><span class="dt-start">2015-07-01t17:30z</span></div>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.equal( result.items[0].properties.start[0], '2015-07-01 17:30Z' ); - - }); - - - - it('get - dateFormat: rfc3339', function(){ - - var doc, - node, - options, - - result; - - var altHTML = '<div class="h-event"><span class="p-name">Pub</span><span class="dt-start">2015-07-01t17:30z</span></div>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'dateFormat': 'rfc3339' - }; - - result = Microformats.get(options); - assert.equal( result.items[0].properties.start[0], '20150701T1730Z' ); - - }); - - - - it('get - filters h-card', function(){ - - var doc, - node, - options, - parser, - result; - - var altHTML = '<div class="h-event"><span class="p-name">Pub</span><span class="dt-start">2015-07-01t17:30z</span></div><a class="h-card" href="http://glennjones.net">Glenn Jones</a>'; - var altExpected = { - 'items': [{ - 'type': ['h-card'], - 'properties': { - 'name': ['Glenn Jones'], - 'url': ['http://glennjones.net'] - } - }], - 'rels': {}, - 'rel-urls': {} - } - - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - - // filter as an array - options ={ - 'node': node, - 'filters': ['h-card'], - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.deepEqual( result, altExpected ); - - // filter as an string - options ={ - 'node': node, - 'filters': 'h-card', - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.deepEqual( result, altExpected ); - }); - - - it('get - filters h-event', function(){ - - var doc, - node, - options, - result; - - var altHTML = '<div class="h-event"><span class="p-name">Pub</span><span class="dt-start">2015-07-01t17:30z</span></div><a class="h-card" href="http://glennjones.net">Glenn Jones</a>'; - var altExpected = { - 'items': [{ - 'type': ['h-event'], - 'properties': { - 'name': ['Pub'], - 'start': ['2015-07-01 17:30Z'] - } - }], - 'rels': {}, - 'rel-urls': {} - } - - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'filters': ['h-event'], - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.deepEqual( result, altExpected ); - - }); - - - it('get - filters h-card and h-event', function(){ - - var doc, - node, - options, - result; - - var altHTML = '<div class="h-event"><span class="p-name">Pub</span><span class="dt-start">2015-07-01t17:30z</span></div><a class="h-card" href="http://glennjones.net">Glenn Jones</a>'; - var altExpected = { - 'items': [{ - 'type': ['h-event'], - 'properties': { - 'name': ['Pub'], - 'start': ['2015-07-01 17:30Z'] - } - }, - { - 'type': ['h-card'], - 'properties': { - 'name': ['Glenn Jones'], - 'url': ['http://glennjones.net'] - } - }], - 'rels': {}, - 'rel-urls': {} - } - - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'filter': ['h-event'], - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.deepEqual( result, altExpected ); - - }); - - - it('get - filters h-card no result', function(){ - - var doc, - node, - options, - result; - - var altHTML = '<div class="h-event"><span class="p-name">Pub</span><span class="dt-start">2015-07-01t17:30z</span></div>'; - var altExpected = { - 'items': [], - 'rels': {}, - 'rel-urls': {} - } - - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'filters': ['h-card'], - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.deepEqual( result, altExpected ); - - }); - - - it('get - filters h-card match v1 format', function(){ - - var doc, - node, - options, - parser, - result; - - var altHTML = '<a class="vcard" href="http://glennjones.net"><span class="fn">Glenn Jones</span></a>'; - var altExpected = { - 'items': [{ - 'type': ['h-card'], - 'properties': { - 'name': ['Glenn Jones'] - } - }], - 'rels': {}, - 'rel-urls': {} - } - - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'filter': ['h-card'], - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.deepEqual( result, altExpected ); - - }); - - - it('get - add new v1 format through options', function(){ - - var doc, - node, - options, - result; - - var altHTML = '<div class="hpayment">£<span class="amount">36.78</span></div>'; - var altExpected = { - 'items': [{ - 'type': ['h-payment'], - 'properties': { - 'amount': ['36.78'] - } - }], - 'rels': {}, - 'rel-urls': {} - }; - var v1Definition = { - root: 'hpayment', - name: 'h-payment', - properties: { - 'amount': {} - } - }; - - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - - options ={ - 'node': node, - 'maps': v1Definition, - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.deepEqual( result, altExpected ); - - }); - - - it('get - options.html', function(){ - - var options, - result; - - options ={ - 'html': html, - 'baseUrl': 'http://example.com', - 'dateFormat': 'html5' - }; - - result = Microformats.get(options); - assert.deepEqual( result, expected ); - - }); - - - - - -}); diff --git a/toolkit/components/microformats/test/interface-tests/getParent-test.js b/toolkit/components/microformats/test/interface-tests/getParent-test.js deleted file mode 100644 index 56ccbb2ba..000000000 --- a/toolkit/components/microformats/test/interface-tests/getParent-test.js +++ /dev/null @@ -1,220 +0,0 @@ -/* -Unit test for getParent -*/ - -assert = chai.assert; - - -describe('Microformat.getParent', function() { - - var HTML = '<div class="h-event"><span class="p-name">Pub</span><span class="dt-start">2015-07-01t17:30z</span></div>'; - var emptyExpected = { - "items": [], - "rels": {}, - "rel-urls": {} - }; - var expected = { - "items": [ - { - "type": [ - "h-event" - ], - "properties": { - "name": [ - "Pub" - ], - "start": [ - "2015-07-01 17:30Z" - ] - } - } - ], - "rels": {}, - "rel-urls": {} - }; - var options = {'dateFormat': 'html5'}; - - - - - it('getParent with parent', function(){ - - var doc, - node, - span, - result; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = HTML; - doc.body.appendChild(node); - span = doc.querySelector('.dt-start'); - - result = Microformats.getParent(span,options); - assert.deepEqual( result, expected ); - - }); - - - - it('getParent without parent', function(){ - - var doc, - node, - parser, - result; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = HTML; - doc.body.appendChild(node); - - result = Microformats.getParent(node,options); - assert.deepEqual( result, emptyExpected ); - - }); - - - it('getParent found with option.filters', function(){ - - var doc, - node, - span, - result; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = HTML; - doc.body.appendChild(node); - span = doc.querySelector('.dt-start'); - - result = Microformats.getParent( span, {'filters': ['h-event'], 'dateFormat': 'html5'} ); - assert.deepEqual( result, expected ); - - }); - - - it('getParent not found with option.filters', function(){ - - var doc, - node, - span, - result; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = HTML; - doc.body.appendChild(node); - span = doc.querySelector('.dt-start'); - - result = Microformats.getParent( span, {'filters': ['h-card'], 'dateFormat': 'html5'} ); - assert.deepEqual( result, emptyExpected ); - - }); - - - it('getParent use option.filters to up through h-*', function(){ - - var doc, - node, - span, - result; - - var altHTML = '<div class="h-entry"><h1 class="p-name">test</h1><div class="e-content">this</div><a class="p-author h-card" href="http://glennjones.net"><span class="p-name">Glenn Jones</span></a><span class="dt-publish">2015-07-01t17:30z</span></div>'; - var altExpected = { - "items": [ - { - "type": [ - "h-entry" - ], - "properties": { - "name": [ - "test" - ], - "content": [ - { - "value": "this", - "html": "this" - } - ], - "author": [ - { - "value": "Glenn Jones", - "type": [ - "h-card" - ], - "properties": { - "name": [ - "Glenn Jones" - ], - "url": [ - "http://glennjones.net" - ] - } - } - ], - "publish": [ - "2015-07-01 17:30Z" - ] - } - } - ], - "rels": {}, - "rel-urls": {} - }; - - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - span = doc.querySelector('.h-card .p-name'); - - result = Microformats.getParent( span, {'filters': ['h-entry'], 'dateFormat': 'html5'} ); - assert.deepEqual( result, altExpected ); - - }); - - - it('getParent stop at first h-* parent', function(){ - - var doc, - node, - span, - result; - - var altHTML = '<div class="h-entry"><h1 class="p-name">test</h1><div class="e-content">this</div><a class="p-author h-card" href="http://glennjones.net"><span class="p-name">Glenn Jones</span></a><span class="dt-publish">2015-07-01t17:30z</span></div>'; - var altExpected = { - "items": [ - { - "type": [ - "h-card" - ], - "properties": { - "name": [ - "Glenn Jones" - ], - "url": [ - "http://glennjones.net" - ] - } - } - ], - "rels": {}, - "rel-urls": {} - }; - - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - node.innerHTML = altHTML; - doc.body.appendChild(node); - span = doc.querySelector('.h-card .p-name'); - - result = Microformats.getParent( span, options ); - assert.deepEqual( result, altExpected ); - - }); - - -}); diff --git a/toolkit/components/microformats/test/interface-tests/hasMicroformats-test.js b/toolkit/components/microformats/test/interface-tests/hasMicroformats-test.js deleted file mode 100644 index 98c79a855..000000000 --- a/toolkit/components/microformats/test/interface-tests/hasMicroformats-test.js +++ /dev/null @@ -1,185 +0,0 @@ -/* -Unit test for hasMicroformat -*/ - -assert = chai.assert; - - -describe('Microformat.hasMicroformats', function() { - - it('true - v2 on node', function(){ - - var doc, - node; - - var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'a' ); - - assert.isTrue( Microformats.hasMicroformats( node ) ); - - }); - - - it('true - v1 on node', function(){ - - var doc, - node; - - var html = '<a class="vcard" href="http://glennjones.net"><span class="fn">Glenn</span></a>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'a' ); - - assert.isTrue( Microformats.hasMicroformats( node ) ); - - }); - - - it('true - v2 filter on node', function(){ - - var doc, - node; - - var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'a' ); - - assert.isTrue( Microformats.hasMicroformats( node, {'filters': ['h-card']} ) ); - - }); - - - it('true - v1 filter on node', function(){ - - var doc, - node; - - var html = '<a class="vcard" href="http://glennjones.net"><span class="fn">Glenn</span></a>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'a' ); - - assert.isTrue( Microformats.hasMicroformats( node, {'filters': ['h-card']} ) ); - - }); - - - it('false - v2 filter on node', function(){ - - var doc, - node; - - var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'a' ); - - assert.isFalse( Microformats.hasMicroformats( node, {'filters': ['h-entry']} ) ); - - }); - - - - it('false - property', function(){ - - var doc, - node, - parser; - - var html = '<span class="p-name">Glenn</span>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'span' ); - - assert.isFalse( Microformats.hasMicroformats( node ) ); - - }); - - - it('false - no class', function(){ - - var doc, - node, - parser; - - var html = '<span>Glenn</span>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'span' ); - - assert.isFalse( Microformats.hasMicroformats( node ) ); - - }); - - - it('false - no node', function(){ - assert.isFalse( Microformats.hasMicroformats( ) ); - }); - - - it('false - undefined node', function(){ - assert.isFalse( Microformats.hasMicroformats( undefined ) ); - }); - - - it('true - child', function(){ - - var doc, - node; - - var html = '<section><div><a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a></div></section>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - - assert.isTrue( Microformats.hasMicroformats( node ) ); - - }); - - - - it('true - document', function(){ - - var doc, - node; - - var html = '<html><head></head><body><section><div><a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a></div></section></body></html>'; - - var dom = new DOMParser(); - doc = dom.parseFromString( html, 'text/html' ); - - assert.isTrue( Microformats.hasMicroformats( doc ) ); - - }); - - - - - - }); diff --git a/toolkit/components/microformats/test/interface-tests/index.html b/toolkit/components/microformats/test/interface-tests/index.html deleted file mode 100644 index 61759790e..000000000 --- a/toolkit/components/microformats/test/interface-tests/index.html +++ /dev/null @@ -1,69 +0,0 @@ -<html><head><title>Mocha</title> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> -<link rel="stylesheet" href="../static/css/mocha.css" /> -<script src="../static/javascript/chai.js"></script> -<script src="../static/javascript/mocha.js"></script> -<link rel="stylesheet" href="../static/css/mocha-custom.css" /> -<link rel="icon" type="image/png" id="favicon" href="chrome://branding/content/icon32.png"/> - -<script src="../static/javascript/DOMParser.js"></script> - -<script data-cover src="../../microformat-shiv.js"></script> - -<script> -var uncaughtError; - -window.addEventListener("error", function(error) { -uncaughtError = error; -}); - -var consoleWarn = console.warn; -var caughtWarnings = []; - -console.warn = function() { -var args = Array.slice(arguments); -caughtWarnings.push(args); -consoleWarn.apply(console, args); -}; -</script> - -<script> -chai.config.includeStack = true; -mocha.setup({ui: 'bdd', timeout: 10000}); -</script> - - -<script src="../interface-tests/get-test.js"></script> -<script src="../interface-tests/getParent-test.js"></script> -<script src="../interface-tests/count-test.js"></script> -<script src="../interface-tests/isMicroformat-test.js"></script> -<script src="../interface-tests/hasMicroformats-test.js"></script> - -<script src="../interface-tests/experimental-test.js"></script> - -</head><body> -<h3 class="capitalize">Microformats-shiv: interface tests</h3> -<div id="mocha"></div> -</body> -<script> -describe("Uncaught Error Check", function() { -it("should load the tests without errors", function() { -chai.expect(uncaughtError && uncaughtError.message).to.be.undefined; -}); -}); - -describe("Unexpected Warnings Check", function() { -it("should long only the warnings we expect", function() { -chai.expect(caughtWarnings.length).to.eql(0); -}); -}); - -mocha.run(function () { -var completeNode = document.createElement("p"); -completeNode.setAttribute("id", "complete"); -completeNode.appendChild(document.createTextNode("Complete")); -document.getElementById("mocha").appendChild(completeNode); -}); - -</script> -</body></html> diff --git a/toolkit/components/microformats/test/interface-tests/isMicroformat-test.js b/toolkit/components/microformats/test/interface-tests/isMicroformat-test.js deleted file mode 100644 index 7081b2880..000000000 --- a/toolkit/components/microformats/test/interface-tests/isMicroformat-test.js +++ /dev/null @@ -1,146 +0,0 @@ -/* -Unit test for isMicroformat -*/ - -assert = chai.assert; - - -describe('Microformat.isMicroformat', function() { - - it('true - v2', function(){ - - var doc, - node; - - var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'a' ); - - assert.isTrue( Microformats.isMicroformat( node ) ); - - }); - - - it('true - v1', function(){ - - var doc, - node; - - var html = '<a class="vcard" href="http://glennjones.net"><span class="fn">Glenn</span></a>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'a' ); - - assert.isTrue( Microformats.isMicroformat( node ) ); - - }); - - - it('true - v2 filter', function(){ - - var doc, - node; - - var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'a' ); - - assert.isTrue( Microformats.isMicroformat( node, {'filters': ['h-card']} ) ); - - }); - - - it('true - v1 filter', function(){ - - var doc, - node; - - var html = '<a class="vcard" href="http://glennjones.net"><span class="fn">Glenn</span></a>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'a' ); - - assert.isTrue( Microformats.isMicroformat( node, {'filters': ['h-card']} ) ); - - }); - - - it('false - v2 filter', function(){ - - var doc, - node; - - var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'a' ); - - assert.isFalse( Microformats.isMicroformat( node, {'filters': ['h-entry']} ) ); - - }); - - - - it('false - property', function(){ - - var doc, - node; - - var html = '<span class="p-name">Glenn</span>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'span' ); - - assert.isFalse( Microformats.isMicroformat( node ) ); - - }); - - - it('false - no class', function(){ - - var doc, - node; - - var html = '<span>Glenn</span>'; - - doc = document.implementation.createHTMLDocument('New Document'); - node = document.createElement('div'); - doc.body.appendChild( node ); - node.innerHTML = html; - node = doc.querySelector( 'span' ); - - assert.isFalse( Microformats.isMicroformat( node ) ); - - }); - - - it('false - no node', function(){ - assert.isFalse( Microformats.isMicroformat( ) ); - }); - - - it('false - undefined node', function(){ - assert.isFalse( Microformats.isMicroformat( undefined ) ); - }); - - }); |