summaryrefslogtreecommitdiffstats
path: root/toolkit/components/microformats/test/interface-tests/count-test.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/components/microformats/test/interface-tests/count-test.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/microformats/test/interface-tests/count-test.js')
-rw-r--r--toolkit/components/microformats/test/interface-tests/count-test.js107
1 files changed, 107 insertions, 0 deletions
diff --git a/toolkit/components/microformats/test/interface-tests/count-test.js b/toolkit/components/microformats/test/interface-tests/count-test.js
new file mode 100644
index 000000000..baac56c2b
--- /dev/null
+++ b/toolkit/components/microformats/test/interface-tests/count-test.js
@@ -0,0 +1,107 @@
+/*
+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} );
+
+ });
+
+
+
+ });