diff options
Diffstat (limited to 'toolkit/components/microformats/test/module-tests')
8 files changed, 0 insertions, 764 deletions
diff --git a/toolkit/components/microformats/test/module-tests/dates-test.js b/toolkit/components/microformats/test/module-tests/dates-test.js deleted file mode 100644 index e5e034190..000000000 --- a/toolkit/components/microformats/test/module-tests/dates-test.js +++ /dev/null @@ -1,113 +0,0 @@ -/* -Unit test for dates -*/ - -assert = chai.assert; - -// Tests the private Modules.dates object -// Modules.dates is unit tested as it has an interface access by other modules - - -describe('Modules.dates', function() { - - - it('hasAM', function(){ - assert.isTrue( Modules.dates.hasAM( '5am' ) ); - assert.isTrue( Modules.dates.hasAM( '5AM' ) ); - assert.isTrue( Modules.dates.hasAM( '5 am' ) ); - assert.isTrue( Modules.dates.hasAM( '5a.m.' ) ); - assert.isTrue( Modules.dates.hasAM( '5:20 a.m.' ) ); - assert.isFalse( Modules.dates.hasAM( '5pm' ) ); - }); - - - it('hasPM', function(){ - assert.isTrue( Modules.dates.hasPM( '5pm' ) ); - assert.isTrue( Modules.dates.hasPM( '5PM' ) ); - assert.isTrue( Modules.dates.hasPM( '5 pm' ) ); - assert.isTrue( Modules.dates.hasPM( '5p.m.' ) ); - assert.isTrue( Modules.dates.hasPM( '5:20 p.m.' ) ); - assert.isFalse( Modules.dates.hasPM( '5am' ) ); - }); - - - it('removeAMPM', function(){ - assert.equal( Modules.dates.removeAMPM( '5pm' ), '5' ); - assert.equal( Modules.dates.removeAMPM( '5 pm' ), '5 ' ); - assert.equal( Modules.dates.removeAMPM( '5p.m.' ), '5' ); - assert.equal( Modules.dates.removeAMPM( '5am' ), '5' ); - assert.equal( Modules.dates.removeAMPM( '5a.m.' ), '5' ); - assert.equal( Modules.dates.removeAMPM( '5' ), '5' ); - }); - - - it('isDuration', function(){ - assert.isTrue( Modules.dates.isDuration( 'PY17M' ) ); - assert.isTrue( Modules.dates.isDuration( 'PW12' ) ); - assert.isTrue( Modules.dates.isDuration( 'P0.5Y' ) ); - assert.isTrue( Modules.dates.isDuration( 'P3Y6M4DT12H30M5S' ) ); - assert.isFalse( Modules.dates.isDuration( '2015-01-23T13:45' ) ); - assert.isFalse( Modules.dates.isDuration( '2015-01-23 13:45' ) ); - assert.isFalse( Modules.dates.isDuration( '20150123T1345' ) ); - }); - - - it('isTime', function(){ - assert.isTrue( Modules.dates.isTime( '8:43' ) ); - assert.isTrue( Modules.dates.isTime( '08:43' ) ); - assert.isTrue( Modules.dates.isTime( '15:23:00:0567' ) ); - assert.isTrue( Modules.dates.isTime( '10:34pm' ) ); - assert.isTrue( Modules.dates.isTime( '10:34 p.m.' ) ); - assert.isTrue( Modules.dates.isTime( '+01:00:00' ) ); - assert.isTrue( Modules.dates.isTime( '-02:00' ) ); - assert.isTrue( Modules.dates.isTime( 'z15:00' ) ); - assert.isTrue( Modules.dates.isTime( '0843' ) ); - assert.isFalse( Modules.dates.isTime( 'P3Y6M4DT12H30M5S' ) ); - assert.isFalse( Modules.dates.isTime( '2015-01-23T13:45' ) ); - assert.isFalse( Modules.dates.isTime( '2015-01-23 13:45' ) ); - assert.isFalse( Modules.dates.isTime( '20150123T1345' ) ); - assert.isFalse( Modules.dates.isTime( 'abc' ) ); - assert.isFalse( Modules.dates.isTime( '12345' ) ); - }); - - - it('parseAmPmTime', function(){ - assert.equal( Modules.dates.parseAmPmTime( '5am' ), '05' ); - assert.equal( Modules.dates.parseAmPmTime( '12pm' ), '12' ); - assert.equal( Modules.dates.parseAmPmTime( '5a.m.' ), '05' ); - assert.equal( Modules.dates.parseAmPmTime( '5pm' ), '17' ); - assert.equal( Modules.dates.parseAmPmTime( '5:34pm' ), '17:34' ); - assert.equal( Modules.dates.parseAmPmTime( '5:04pm' ), '17:04' ); - assert.equal( Modules.dates.parseAmPmTime( '05:34:00' ), '05:34:00' ); - assert.equal( Modules.dates.parseAmPmTime( '05:34:00' ), '05:34:00' ); - assert.equal( Modules.dates.parseAmPmTime( '1:52:04pm' ), '13:52:04' ); - }); - - - it('dateTimeUnion', function(){ - assert.equal( Modules.dates.dateTimeUnion( '2015-01-23', '05:34:00', 'HTML5' ).toString('HTML5'), '2015-01-23 05:34:00' ); - assert.equal( Modules.dates.dateTimeUnion( '2015-01-23', '05:34', 'HTML5' ).toString('HTML5'), '2015-01-23 05:34' ); - assert.equal( Modules.dates.dateTimeUnion( '2015-01-23', '05', 'HTML5' ).toString('HTML5'), '2015-01-23 05' ); - assert.equal( Modules.dates.dateTimeUnion( '2009-06-26T19:00', '2200', 'HTML5' ).toString('HTML5'), '2009-06-26 22:00' ); - - assert.equal( Modules.dates.dateTimeUnion( '2015-01-23', '', 'HTML5' ).toString('HTML5'), '2015-01-23' ); - assert.equal( Modules.dates.dateTimeUnion( '', '', 'HTML5' ).toString('HTML5'), '' ); - }); - - - it('concatFragments', function(){ - assert.equal( Modules.dates.concatFragments( ['2015-01-23', '05:34:00'], 'HTML5' ).toString('HTML5'), '2015-01-23 05:34:00' ); - assert.equal( Modules.dates.concatFragments( ['05:34:00', '2015-01-23'], 'HTML5' ).toString('HTML5'), '2015-01-23 05:34:00' ); - assert.equal( Modules.dates.concatFragments( ['2015-01-23T05:34:00'], 'HTML5' ).toString('HTML5'), '2015-01-23 05:34:00' ); - assert.equal( Modules.dates.concatFragments( ['2015-01-23', '05:34:00', 'z'], 'HTML5' ).toString('HTML5'), '2015-01-23 05:34:00Z' ); - assert.equal( Modules.dates.concatFragments( ['2015-01-23', '05:34', '-01'], 'HTML5' ).toString('HTML5'), '2015-01-23 05:34-01' ); - assert.equal( Modules.dates.concatFragments( ['2015-01-23', '05:34', '-01:00'], 'HTML5' ).toString('HTML5'), '2015-01-23 05:34-01:00' ); - assert.equal( Modules.dates.concatFragments( ['2015-01-23', '05:34-01:00'], 'HTML5' ).toString('HTML5'), '2015-01-23 05:34-01:00' ); - - }); - - - - - -}); 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] ); - }); - - -}); diff --git a/toolkit/components/microformats/test/module-tests/html-test.js b/toolkit/components/microformats/test/module-tests/html-test.js deleted file mode 100644 index cd06c7b7f..000000000 --- a/toolkit/components/microformats/test/module-tests/html-test.js +++ /dev/null @@ -1,50 +0,0 @@ -/* -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 ), '' ); - - }); - - - - - - - - -}); diff --git a/toolkit/components/microformats/test/module-tests/index.html b/toolkit/components/microformats/test/module-tests/index.html deleted file mode 100644 index 0eb3c2040..000000000 --- a/toolkit/components/microformats/test/module-tests/index.html +++ /dev/null @@ -1,76 +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="../lib/utilities.js"></script> -<script data-cover src="../lib/domutils.js"></script> -<script data-cover src="../lib/url.js"></script> -<script data-cover src="../lib/html.js"></script> -<script data-cover src="../lib/text.js"></script> -<script data-cover src="../lib/dates.js"></script> -<script data-cover src="../lib/isodate.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="../module-tests/dates-test.js"></script> -<script src="../module-tests/domUtils-test.js"></script> -<script src="../module-tests/html-test.js"></script> -<script src="../module-tests/isodate-test.js"></script> -<script src="../module-tests/text-test.js"></script> - -<script src="../module-tests/url-test.js"></script> - -<script src="../module-tests/utilities-test.js"></script> - -</head><body> -<h3 class="capitalize">Microformats-shiv: module 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/module-tests/isodate-test.js b/toolkit/components/microformats/test/module-tests/isodate-test.js deleted file mode 100644 index 5f081f81c..000000000 --- a/toolkit/components/microformats/test/module-tests/isodate-test.js +++ /dev/null @@ -1,145 +0,0 @@ -/* -Unit test for dates -*/ - -assert = chai.assert; - - -// Tests private Modules.ISODate object -// Modules.ISODate is unit tested as it has an interface access by other modules - - -describe('Modules.ISODates', function() { - - - - it('constructor', function(){ - assert.equal( new Modules.ISODate().toString('auto'), '' ); - assert.equal( new Modules.ISODate('2015-01-23T05:34:00', 'html5').toString('html5'), '2015-01-23 05:34:00' ); - assert.equal( new Modules.ISODate('2015-01-23T05:34:00', 'w3c').toString('w3c'), '2015-01-23T05:34:00' ); - assert.equal( new Modules.ISODate('2015-01-23T05:34:00', 'html5').toString('rfc3339'), '20150123T053400' ); - assert.equal( new Modules.ISODate('2015-01-23T05:34:00', 'auto').toString('auto'), '2015-01-23T05:34:00' ); - }); - - - it('parse', function(){ - assert.equal( new Modules.ISODate().parse('2015-01-23T05:34:00', 'html5').toString('html5'), '2015-01-23 05:34:00' ); - assert.equal( new Modules.ISODate().parse('2015-01-23T05:34:00', 'auto').toString('auto'), '2015-01-23T05:34:00' ); - assert.equal( new Modules.ISODate().parse('2015-01-23t05:34:00', 'auto').toString('auto'), '2015-01-23t05:34:00' ); - - assert.equal( new Modules.ISODate().parse('2015-01-23t05:34:00Z', 'auto').toString('auto'), '2015-01-23t05:34:00Z' ); - assert.equal( new Modules.ISODate().parse('2015-01-23t05:34:00z', 'auto').toString('auto'), '2015-01-23t05:34:00z' ); - assert.equal( new Modules.ISODate().parse('2015-01-23 05:34:00Z', 'auto').toString('auto'), '2015-01-23 05:34:00Z' ); - assert.equal( new Modules.ISODate().parse('2015-01-23 05:34', 'auto').toString('auto'), '2015-01-23 05:34' ); - assert.equal( new Modules.ISODate().parse('2015-01-23 05', 'auto').toString('auto'), '2015-01-23 05' ); - - assert.equal( new Modules.ISODate().parse('2015-01-23 05:34+01:00', 'auto').toString('auto'), '2015-01-23 05:34+01:00' ); - assert.equal( new Modules.ISODate().parse('2015-01-23 05:34-01:00', 'auto').toString('auto'), '2015-01-23 05:34-01:00' ); - assert.equal( new Modules.ISODate().parse('2015-01-23 05:34-01', 'auto').toString('auto'), '2015-01-23 05:34-01' ); - - - assert.equal( new Modules.ISODate().parse('2015-01-23', 'auto').toString('auto'), '2015-01-23' ); - // TODO support for importing rfc3339 profile dates - // assert.equal( new Modules.ISODate().parse('20150123t0534', 'auto').toString('auto'), '2015-01-23 05:34' ); - }); - - - it('parseDate', function(){ - assert.equal( new Modules.ISODate().parseDate('2015-01-23T05:34:00', 'html5'), '2015-01-23' ); - assert.equal( new Modules.ISODate().parseDate('2015-01-23', 'auto'), '2015-01-23' ); - assert.equal( new Modules.ISODate().parseDate('2015-01', 'auto'), '2015-01' ); - assert.equal( new Modules.ISODate().parseDate('2015', 'auto'), '2015' ); - assert.equal( new Modules.ISODate().parseDate('2015-134', 'auto'), '2015-134' ); - }); - - - it('parseTime', function(){ - assert.equal( new Modules.ISODate().parseTime('05:34:00.1267', 'html5'), '05:34:00.1267' ); - assert.equal( new Modules.ISODate().parseTime('05:34:00', 'html5'), '05:34:00' ); - assert.equal( new Modules.ISODate().parseTime('05:34', 'html5'), '05:34' ); - assert.equal( new Modules.ISODate().parseTime('05', 'html5'), '05' ); - }); - - it('parseTimeZone', function(){ - var date = new Modules.ISODate(); - date.parseTime('14:00'); - assert.equal( date.parseTimeZone('-01:00', 'auto'), '14:00-01:00' ); - - date.clear(); - date.parseTime('14:00'); - assert.equal( date.parseTimeZone('-01', 'auto'), '14:00-01' ); - - date.clear(); - date.parseTime('14:00'); - assert.equal( date.parseTimeZone('+01:00', 'auto').toString('auto'), '14:00+01:00' ); - - date.clear(); - date.parseTime('15:00'); - assert.equal( date.parseTimeZone('Z', 'auto').toString('auto'), '15:00Z' ); - - date.clear(); - date.parseTime('16:00'); - assert.equal( date.parseTimeZone('z', 'auto'), '16:00z' ); - - }); - - - - it('toString', function(){ - var date = new Modules.ISODate(); - date.parseTime('05:34:00.1267'); - - assert.equal( date.toString('html5'), '05:34:00.1267' ); - }); - - - it('toTimeString', function(){ - var date = new Modules.ISODate(); - date.parseTime('05:34:00.1267'); - - assert.equal( date.toTimeString('html5'), '05:34:00.1267' ); - }); - - - it('hasFullDate', function(){ - var dateEmpty = new Modules.ISODate(), - date = new Modules.ISODate('2015-01-23T05:34:00'); - - assert.isFalse( dateEmpty.hasFullDate() ); - assert.isTrue( date.hasFullDate() ); - }); - - - it('hasDate', function(){ - var dateEmpty = new Modules.ISODate(), - date = new Modules.ISODate('2015-01-23'); - - assert.isFalse( dateEmpty.hasDate() ); - assert.isTrue( date.hasDate() ); - }); - - - it('hasTime', function(){ - var dateEmpty = new Modules.ISODate(), - date = new Modules.ISODate(); - - date.parseTime('12:34'); - - assert.isFalse( dateEmpty.hasTime() ); - assert.isTrue( date.hasTime() ); - }); - - - it('hasTimeZone', function(){ - var dateEmpty = new Modules.ISODate(), - date = new Modules.ISODate(); - - date.parseTime('12:34'), - date.parseTimeZone('-01:00'); - - assert.isFalse( dateEmpty.hasTimeZone() ); - assert.isTrue( date.hasTimeZone() ); - }); - - -}); diff --git a/toolkit/components/microformats/test/module-tests/text-test.js b/toolkit/components/microformats/test/module-tests/text-test.js deleted file mode 100644 index f1f2e775c..000000000 --- a/toolkit/components/microformats/test/module-tests/text-test.js +++ /dev/null @@ -1,56 +0,0 @@ -/* -Unit test for text -*/ - -assert = chai.assert; - -// Tests the private Modules.text object -// Modules.text is unit tested as it has an interface access by other modules - - -describe('Modules.text', function() { - - - it('parse', function(){ - var html = '\n <a href="http://glennjones.net">Glenn\n Jones \n</a> \n', - node = document.createElement('div'); - - node.innerHTML = html; - assert.equal( Modules.text.parse( document, node, 'whitespacetrimmed' ), 'Glenn\n Jones' ); - assert.equal( Modules.text.parse( document, node, 'whitespace' ), '\n Glenn\n Jones \n \n' ); - assert.equal( Modules.text.parse( document, node, 'normalised' ), 'Glenn Jones' ); - - // exclude tags - node.innerHTML = '<script>test</script>text'; - assert.equal( Modules.text.parse( document, node, 'normalised' ), 'text' ); - - // block level - node.innerHTML = '<p>test</p>text'; - //assert.equal( Modules.text.parse( document, node, 'normalised' ), 'test text' ); - - // node with no text data - node = document.createComment('test comment'); - assert.equal( Modules.text.parse( document, node, 'normalised' ), '' ); - - }); - - - it('parseText', function(){ - var text = '\n <a href="http://glennjones.net">Glenn\n Jones \n</a> \n'; - - // create DOM context first - Modules.domUtils.getDOMContext( {} ); - - assert.equal( Modules.text.parseText( document, text, 'whitespacetrimmed' ), 'Glenn\n Jones' ); - assert.equal( Modules.text.parseText( document, text, 'whitespace' ), '\n Glenn\n Jones \n \n' ); - assert.equal( Modules.text.parseText( document, text, 'normalised' ), 'Glenn Jones' ); - }); - - - it('formatText', function(){ - assert.equal( Modules.text.formatText( document, null, 'whitespacetrimmed' ), '' ); - }); - - - -}); diff --git a/toolkit/components/microformats/test/module-tests/url-test.js b/toolkit/components/microformats/test/module-tests/url-test.js deleted file mode 100644 index 788e8fdb5..000000000 --- a/toolkit/components/microformats/test/module-tests/url-test.js +++ /dev/null @@ -1,25 +0,0 @@ -/* -Unit test for url -*/ - -assert = chai.assert; - - -// Tests the private Modules.url object -// Modules.url is unit tested as it has an interface access by other modules - - -describe('Modules.url', function() { - - it('resolve', function(){ - assert.equal( Modules.url.resolve( 'docs/index.html', 'http://example.org' ), 'http://example.org/docs/index.html' ); - assert.equal( Modules.url.resolve( '../index.html', 'http://example.org/docs/' ), 'http://example.org/index.html' ); - assert.equal( Modules.url.resolve( '/', 'http://example.org/' ), 'http://example.org/' ); - assert.equal( Modules.url.resolve( 'http://glennjones.net/', 'http://example.org/' ), 'http://glennjones.net/' ); - - assert.equal( Modules.url.resolve( undefined, 'http://example.org/' ), '' ); - assert.equal( Modules.url.resolve( undefined, undefined ), '' ); - assert.equal( Modules.url.resolve( 'http://glennjones.net/', undefined ), 'http://glennjones.net/' ); - }); - -}); diff --git a/toolkit/components/microformats/test/module-tests/utilities-test.js b/toolkit/components/microformats/test/module-tests/utilities-test.js deleted file mode 100644 index b37236a6b..000000000 --- a/toolkit/components/microformats/test/module-tests/utilities-test.js +++ /dev/null @@ -1,93 +0,0 @@ -/* -Unit test for utilities -*/ - -assert = chai.assert; - -// Tests the private Modules.utils object -// Modules.utils is unit tested as it has an interface access by other modules - - -describe('Modules.utilities', function() { - - - it('isString', function(){ - assert.isTrue( Modules.utils.isString( 'abc' ) ); - assert.isFalse( Modules.utils.isString( 123 ) ); - assert.isFalse( Modules.utils.isString( 1.23 ) ); - assert.isFalse( Modules.utils.isString( {'abc': 'abc'} ) ); - assert.isFalse( Modules.utils.isString( ['abc'] ) ); - assert.isFalse( Modules.utils.isString( true ) ); - }); - - - it('isArray', function(){ - assert.isTrue( Modules.utils.isArray( ['abc'] ) ); - assert.isFalse( Modules.utils.isArray( 123 ) ); - assert.isFalse( Modules.utils.isArray( 1.23 ) ); - assert.isFalse( Modules.utils.isArray( 'abc' ) ); - assert.isFalse( Modules.utils.isArray( {'abc': 'abc'} ) ); - assert.isFalse( Modules.utils.isArray( true ) ); - }); - - - it('isNumber', function(){ - assert.isTrue( Modules.utils.isNumber( 123 ) ); - assert.isTrue( Modules.utils.isNumber( 1.23 ) ); - assert.isFalse( Modules.utils.isNumber( 'abc' ) ); - assert.isFalse( Modules.utils.isNumber( {'abc': 'abc'} ) ); - assert.isFalse( Modules.utils.isNumber( ['abc'] ) ); - assert.isFalse( Modules.utils.isNumber( true ) ); - }); - - - it('startWith', function(){ - assert.isTrue( Modules.utils.startWith( 'p-name', 'p-' ) ); - assert.isFalse( Modules.utils.startWith( 'p-name', 'name' ) ); - assert.isFalse( Modules.utils.startWith( 'p-name', 'u-' ) ); - }); - - - it('trim', function(){ - assert.equal( Modules.utils.trim( ' Glenn Jones ' ), 'Glenn Jones' ); - assert.equal( Modules.utils.trim( 'Glenn Jones' ), 'Glenn Jones' ); - assert.equal( Modules.utils.trim( undefined ), '' ); - }); - - - it('replaceCharAt', function(){ - assert.equal( Modules.utils.replaceCharAt( 'Glenn Jones', 5, '-' ), 'Glenn-Jones' ); - assert.equal( Modules.utils.replaceCharAt( 'Glenn Jones', 50, '-' ), 'Glenn Jones' ); - }); - - - it('isOnlyWhiteSpace', function(){ - assert.isTrue( Modules.utils.isOnlyWhiteSpace( ' ') ); - assert.isTrue( Modules.utils.isOnlyWhiteSpace( ' \n\r') ); - assert.isFalse( Modules.utils.isOnlyWhiteSpace( ' text\n\r') ); - }); - - - it('collapseWhiteSpace', function(){ - assert.equal( Modules.utils.collapseWhiteSpace( ' '), ' ' ); - assert.equal( Modules.utils.collapseWhiteSpace( ' \n\r'), ' ' ); - assert.equal( Modules.utils.collapseWhiteSpace( ' text\n\r'), ' text ' ); - }); - - - it('hasProperties', function(){ - assert.isTrue( Modules.utils.hasProperties( {name: 'glennjones'} ) ); - assert.isFalse( Modules.utils.hasProperties( {} ) ); - }); - - - it('sortObjects', function(){ - var arr = [{'name': 'one'},{'name': 'two'},{'name': 'three'},{'name': 'three'}]; - - assert.deepEqual( arr.sort( Modules.utils.sortObjects( 'name', true ) ), [{"name":"two"},{"name":"three"},{'name': 'three'},{"name":"one"}] ); - assert.deepEqual( arr.sort( Modules.utils.sortObjects( 'name', false ) ), [{"name":"one"},{"name":"three"},{'name': 'three'},{"name":"two"}] ); - }); - - - -}); |