summaryrefslogtreecommitdiffstats
path: root/toolkit/components/microformats/test/module-tests/html-test.js
blob: cd06c7b7f787022713a20bb553955fdec5dd2608 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
Unit test for html
*/

assert = chai.assert;

// Tests the private Modules.html object
// Modules.html is unit tested as it has an interface access by other modules

describe('Modules.html', function() {


   it('parse', function(){
       var html = '<a href="http://glennjones.net">Glenn Jones</a>',
           bloghtml = '<section id="content" class="body"><ol id="posts-list" class="h-feed"><li><article class="h-entry"><header><h2 class="p-namee"><a href="#" rel="bookmark" title="Permalink to this POST TITLE">This be the title</a></h2></header><footer class="post-info"><abbr class="dt-published" title="2005-10-10T14:07:00-07:00">10th October 2005</abbr><address class="h-card p-author">By <a class="u-url p-name" href="#">Enrique Ramírez</a></address></footer><div class="e-content"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque venenatis nunc vitae libero iaculis elementum. Nullam et justo <a href="#">non sapien</a> dapibus blandit nec et leo. Ut ut malesuada tellus.</p></div></article></li></ol></section>',
           node = document.createElement('div');

       node.innerHTML = html;
       assert.equal(Modules.html.parse( node ), html );

       // make sure excludes 'data-include' marked items
       var child = document.createElement('p');
       child.setAttribute('data-include', 'true');
       node.appendChild(child);
       assert.equal( Modules.html.parse( node ), html );

       node = document.createElement('div');
       node.innerHTML = bloghtml;
       assert.equal( Modules.html.parse( node ), bloghtml );

       node = document.createElement('div');
       assert.equal( Modules.html.parse( node ), '' );

       child = document.createElement('br');
       node.appendChild(child);
       assert.equal( Modules.html.parse( node ), '<br />' );

       node = document.createComment('test comment');
       assert.equal( Modules.html.parse( node ), '' );

   });








});