Bug 1037483 adopt microformats-shiv for microformats v2 support, r=tantek

This commit is contained in:
Shane Caraveo 2016-01-26 10:52:59 -08:00
parent 3e3f5f0eb8
commit 71d96c6ddf
196 changed files with 31008 additions and 2 deletions

View File

@ -20,3 +20,6 @@ test_container = true
; loop tests
[include:../../../../../browser/extensions/loop/manifest.ini]
; microformats tests
[include:../../../../../toolkit/components/microformats/manifest.ini]

View File

@ -0,0 +1,9 @@
[DEFAULT]
b2g = false
browser = true
qemu = false
[test/marionette/test_standards.py]
[test/marionette/test_modules.py]
[test/marionette/test_interface.py]

File diff suppressed because it is too large Load Diff

View File

@ -4,9 +4,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
EXTRA_JS_MODULES += [
'microformat-shiv.js',
'Microformats.js',
]

View File

@ -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} );
});
});

View File

@ -0,0 +1,37 @@
/*
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 );
});
});

View File

@ -0,0 +1,595 @@
/*
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);
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 );
});
});

View File

@ -0,0 +1,220 @@
/*
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 );
});
});

View File

@ -0,0 +1,185 @@
/*
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 ) );
});
});

View File

@ -0,0 +1,68 @@
<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" />
<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>

View File

@ -0,0 +1,146 @@
/*
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 ) );
});
});

View File

@ -0,0 +1,268 @@
/*!
dates
These functions are based on microformats implied rules for parsing date fragments from text.
They are not generalist date utilities and should only be used with the isodate.js module of this library.
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
Dependencies utilities.js, isodate.js
*/
var Modules = (function (modules) {
modules.dates = {
/**
* does text contain am
*
* @param {String} text
* @return {Boolean}
*/
hasAM: function( text ) {
text = text.toLowerCase();
return(text.indexOf('am') > -1 || text.indexOf('a.m.') > -1);
},
/**
* does text contain pm
*
* @param {String} text
* @return {Boolean}
*/
hasPM: function( text ) {
text = text.toLowerCase();
return(text.indexOf('pm') > -1 || text.indexOf('p.m.') > -1);
},
/**
* remove am and pm from text and return it
*
* @param {String} text
* @return {String}
*/
removeAMPM: function( text ) {
return text.replace('pm', '').replace('p.m.', '').replace('am', '').replace('a.m.', '');
},
/**
* simple test of whether ISO date string is a duration i.e. PY17M or PW12
*
* @param {String} text
* @return {Boolean}
*/
isDuration: function( text ) {
if(modules.utils.isString( text )){
text = text.toLowerCase();
if(modules.utils.startWith(text, 'p') ){
return true;
}
}
return false;
},
/**
* is text a time or timezone
* i.e. HH-MM-SS or z+-HH-MM-SS 08:43 | 15:23:00:0567 | 10:34pm | 10:34 p.m. | +01:00:00 | -02:00 | z15:00 | 0843
*
* @param {String} text
* @return {Boolean}
*/
isTime: function( text ) {
if(modules.utils.isString(text)){
text = text.toLowerCase();
text = modules.utils.trim( text );
// start with timezone char
if( text.match(':') && ( modules.utils.startWith(text, 'z') || modules.utils.startWith(text, '-') || modules.utils.startWith(text, '+') )) {
return true;
}
// has ante meridiem or post meridiem
if( text.match(/^[0-9]/) &&
( this.hasAM(text) || this.hasPM(text) )) {
return true;
}
// contains time delimiter but not datetime delimiter
if( text.match(':') && !text.match(/t|\s/) ) {
return true;
}
// if it's a number of 2, 4 or 6 chars
if(modules.utils.isNumber(text)){
if(text.length === 2 || text.length === 4 || text.length === 6){
return true;
}
}
}
return false;
},
/**
* parses a time from text and returns 24hr time string
* i.e. 5:34am = 05:34:00 and 1:52:04p.m. = 13:52:04
*
* @param {String} text
* @return {String}
*/
parseAmPmTime: function( text ) {
var out = text,
times = [];
// if the string has a text : or am or pm
if(modules.utils.isString(out)) {
//text = text.toLowerCase();
text = text.replace(/[ ]+/g, '');
if(text.match(':') || this.hasAM(text) || this.hasPM(text)) {
if(text.match(':')) {
times = text.split(':');
} else {
// single number text i.e. 5pm
times[0] = text;
times[0] = this.removeAMPM(times[0]);
}
// change pm hours to 24hr number
if(this.hasPM(text)) {
if(times[0] < 12) {
times[0] = parseInt(times[0], 10) + 12;
}
}
// add leading zero's where needed
if(times[0] && times[0].length === 1) {
times[0] = '0' + times[0];
}
// rejoin text elements together
if(times[0]) {
text = times.join(':');
}
}
}
// remove am/pm strings
return this.removeAMPM(text);
},
/**
* overlays a time on a date to return the union of the two
*
* @param {String} date
* @param {String} time
* @param {String} format ( Modules.ISODate profile format )
* @return {Object} Modules.ISODate
*/
dateTimeUnion: function(date, time, format) {
var isodate = new modules.ISODate(date, format),
isotime = new modules.ISODate();
isotime.parseTime(this.parseAmPmTime(time), format);
if(isodate.hasFullDate() && isotime.hasTime()) {
isodate.tH = isotime.tH;
isodate.tM = isotime.tM;
isodate.tS = isotime.tS;
isodate.tD = isotime.tD;
return isodate;
} else {
if(isodate.hasFullDate()){
return isodate;
}
return new modules.ISODate();
}
},
/**
* concatenate an array of date and time text fragments to create an ISODate object
* used for microformat value and value-title rules
*
* @param {Array} arr ( Array of Strings )
* @param {String} format ( Modules.ISODate profile format )
* @return {Object} Modules.ISODate
*/
concatFragments: function (arr, format) {
var out = new modules.ISODate(),
i = 0,
value = '';
// if the fragment already contains a full date just return it once
if(arr[0].toUpperCase().match('T')) {
return new modules.ISODate(arr[0], format);
}else{
for(i = 0; i < arr.length; i++) {
value = arr[i];
// date pattern
if( value.charAt(4) === '-' && out.hasFullDate() === false ){
out.parseDate(value);
}
// time pattern
if( (value.indexOf(':') > -1 || modules.utils.isNumber( this.parseAmPmTime(value) )) && out.hasTime() === false ) {
// split time and timezone
var items = this.splitTimeAndZone(value);
value = items[0];
// parse any use of am/pm
value = this.parseAmPmTime(value);
out.parseTime(value);
// parse any timezone
if(items.length > 1){
out.parseTimeZone(items[1], format);
}
}
// timezone pattern
if(value.charAt(0) === '-' || value.charAt(0) === '+' || value.toUpperCase() === 'Z') {
if( out.hasTimeZone() === false ){
out.parseTimeZone(value);
}
}
}
return out;
}
},
/**
* parses text by splitting it into an array of time and timezone strings
*
* @param {String} text
* @return {Array} Modules.ISODate
*/
splitTimeAndZone: function ( text ){
var out = [text],
chars = ['-','+','z','Z'],
i = chars.length;
while (i--) {
if(text.indexOf(chars[i]) > -1){
out[0] = text.slice( 0, text.indexOf(chars[i]) );
out.push( text.slice( text.indexOf(chars[i]) ) );
break;
}
}
return out;
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,103 @@
// Based on https://gist.github.com/1129031 By Eli Grey, http://eligrey.com - Public domain.
// DO NOT use https://developer.mozilla.org/en-US/docs/Web/API/DOMParser example polyfill
// as it does not work with earlier versions of Chrome
(function(DOMParser) {
'use strict';
var DOMParser_proto;
var real_parseFromString;
var textHTML; // Flag for text/html support
var textXML; // Flag for text/xml support
var htmlElInnerHTML; // Flag for support for setting html element's innerHTML
// Stop here if DOMParser not defined
if (!DOMParser) {
return;
}
// Firefox, Opera and IE throw errors on unsupported types
try {
// WebKit returns null on unsupported types
textHTML = !!(new DOMParser()).parseFromString('', 'text/html');
} catch (er) {
textHTML = false;
}
// If text/html supported, don't need to do anything.
if (textHTML) {
return;
}
// Next try setting innerHTML of a created document
// IE 9 and lower will throw an error (can't set innerHTML of its HTML element)
try {
var doc = document.implementation.createHTMLDocument('');
doc.documentElement.innerHTML = '<title></title><div></div>';
htmlElInnerHTML = true;
} catch (er) {
htmlElInnerHTML = false;
}
// If if that failed, try text/xml
if (!htmlElInnerHTML) {
try {
textXML = !!(new DOMParser()).parseFromString('', 'text/xml');
} catch (er) {
textHTML = false;
}
}
// Mess with DOMParser.prototype (less than optimal...) if one of the above worked
// Assume can write to the prototype, if not, make this a stand alone function
if (DOMParser.prototype && (htmlElInnerHTML || textXML)) {
DOMParser_proto = DOMParser.prototype;
real_parseFromString = DOMParser_proto.parseFromString;
DOMParser_proto.parseFromString = function (markup, type) {
// Only do this if type is text/html
if (/^\s*text\/html\s*(?:;|$)/i.test(type)) {
var doc, doc_el, first_el;
// Use innerHTML if supported
if (htmlElInnerHTML) {
doc = document.implementation.createHTMLDocument('');
doc_el = doc.documentElement;
doc_el.innerHTML = markup;
first_el = doc_el.firstElementChild;
// Otherwise use XML method
} else if (textXML) {
// Make sure markup is wrapped in HTML tags
// Should probably allow for a DOCTYPE
if (!(/^<html.*html>$/i.test(markup))) {
markup = '<html>' + markup + '<\/html>';
}
doc = (new DOMParser()).parseFromString(markup, 'text/xml');
doc_el = doc.documentElement;
first_el = doc_el.firstElementChild;
}
// Is this an entire document or a fragment?
if (doc_el.childElementCount === 1 && first_el.localName.toLowerCase() === 'html') {
doc.replaceChild(first_el, doc_el);
}
return doc;
// If not text/html, send as-is to host method
} else {
return real_parseFromString.apply(this, arguments);
}
};
}
}(DOMParser));

View File

@ -0,0 +1,611 @@
/*
dom utilities
The purpose of this module is to abstract DOM functions away from the main parsing modules of the library.
It was created so the file can be replaced in node.js environment to make use of different types of light weight node.js DOM's
such as 'cherrio.js'. It also contains a number of DOM utilities which are used throughout the parser such as: 'getDescendant'
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
Dependencies utilities.js
*/
var Modules = (function (modules) {
modules.domUtils = {
// blank objects for DOM
document: null,
rootNode: null,
/**
* gets DOMParser object
*
* @return {Object || undefined}
*/
getDOMParser: function () {
if (typeof DOMParser === undefined) {
try {
return Components.classes["@mozilla.org/xmlextras/domparser;1"]
.createInstance(Components.interfaces.nsIDOMParser);
} catch (e) {
return;
}
} else {
return new DOMParser();
}
},
/**
* configures what are the base DOM objects for parsing
*
* @param {Object} options
* @return {DOM Node} node
*/
getDOMContext: function( options ){
// if a node is passed
if(options.node){
this.rootNode = options.node;
}
// if a html string is passed
if(options.html){
//var domParser = new DOMParser();
var domParser = this.getDOMParser();
this.rootNode = domParser.parseFromString( options.html, 'text/html' );
}
// find top level document from rootnode
if(this.rootNode !== null){
if(this.rootNode.nodeType === 9){
this.document = this.rootNode;
this.rootNode = modules.domUtils.querySelector(this.rootNode, 'html');
}else{
// if it's DOM node get parent DOM Document
this.document = modules.domUtils.ownerDocument(this.rootNode);
}
}
// use global document object
if(!this.rootNode && document){
this.rootNode = modules.domUtils.querySelector(document, 'html');
this.document = document;
}
if(this.rootNode && this.document){
return {document: this.document, rootNode: this.rootNode};
}
return {document: null, rootNode: null};
},
/**
* gets the first DOM node
*
* @param {Dom Document}
* @return {DOM Node} node
*/
getTopMostNode: function( node ){
//var doc = this.ownerDocument(node);
//if(doc && doc.nodeType && doc.nodeType === 9 && doc.documentElement){
// return doc.documentElement;
//}
return node;
},
/**
* abstracts DOM ownerDocument
*
* @param {DOM Node} node
* @return {Dom Document}
*/
ownerDocument: function(node){
return node.ownerDocument;
},
/**
* abstracts DOM textContent
*
* @param {DOM Node} node
* @return {String}
*/
textContent: function(node){
if(node.textContent){
return node.textContent;
}else if(node.innerText){
return node.innerText;
}
return '';
},
/**
* abstracts DOM innerHTML
*
* @param {DOM Node} node
* @return {String}
*/
innerHTML: function(node){
return node.innerHTML;
},
/**
* abstracts DOM hasAttribute
*
* @param {DOM Node} node
* @param {String} attributeName
* @return {Boolean}
*/
hasAttribute: function(node, attributeName) {
return node.hasAttribute(attributeName);
},
/**
* does an attribute contain a value
*
* @param {DOM Node} node
* @param {String} attributeName
* @param {String} value
* @return {Boolean}
*/
hasAttributeValue: function(node, attributeName, value) {
return (this.getAttributeList(node, attributeName).indexOf(value) > -1);
},
/**
* abstracts DOM getAttribute
*
* @param {DOM Node} node
* @param {String} attributeName
* @return {String || null}
*/
getAttribute: function(node, attributeName) {
return node.getAttribute(attributeName);
},
/**
* abstracts DOM setAttribute
*
* @param {DOM Node} node
* @param {String} attributeName
* @param {String} attributeValue
*/
setAttribute: function(node, attributeName, attributeValue){
node.setAttribute(attributeName, attributeValue);
},
/**
* abstracts DOM removeAttribute
*
* @param {DOM Node} node
* @param {String} attributeName
*/
removeAttribute: function(node, attributeName) {
node.removeAttribute(attributeName);
},
/**
* abstracts DOM getElementById
*
* @param {DOM Node || DOM Document} node
* @param {String} id
* @return {DOM Node}
*/
getElementById: function(docNode, id) {
return docNode.querySelector( '#' + id );
},
/**
* abstracts DOM querySelector
*
* @param {DOM Node || DOM Document} node
* @param {String} selector
* @return {DOM Node}
*/
querySelector: function(docNode, selector) {
return docNode.querySelector( selector );
},
/**
* get value of a Node attribute as an array
*
* @param {DOM Node} node
* @param {String} attributeName
* @return {Array}
*/
getAttributeList: function(node, attributeName) {
var out = [],
attList;
attList = node.getAttribute(attributeName);
if(attList && attList !== '') {
if(attList.indexOf(' ') > -1) {
out = attList.split(' ');
} else {
out.push(attList);
}
}
return out;
},
/**
* gets all child nodes with a given attribute
*
* @param {DOM Node} node
* @param {String} attributeName
* @return {NodeList}
*/
getNodesByAttribute: function(node, attributeName) {
var selector = '[' + attributeName + ']';
return node.querySelectorAll(selector);
},
/**
* gets all child nodes with a given attribute containing a given value
*
* @param {DOM Node} node
* @param {String} attributeName
* @return {DOM NodeList}
*/
getNodesByAttributeValue: function(rootNode, name, value) {
var arr = [],
x = 0,
i,
out = [];
arr = this.getNodesByAttribute(rootNode, name);
if(arr) {
i = arr.length;
while(x < i) {
if(this.hasAttributeValue(arr[x], name, value)) {
out.push(arr[x]);
}
x++;
}
}
return out;
},
/**
* gets attribute value from controlled list of tags
*
* @param {Array} tagNames
* @param {String} attributeName
* @return {String || null}
*/
getAttrValFromTagList: function(node, tagNames, attributeName) {
var i = tagNames.length;
while(i--) {
if(node.tagName.toLowerCase() === tagNames[i]) {
var attrValue = this.getAttribute(node, attributeName);
if(attrValue && attrValue !== '') {
return attrValue;
}
}
}
return null;
},
/**
* get node if it has no siblings. CSS equivalent is :only-child
*
* @param {DOM Node} rootNode
* @param {Array} tagNames
* @return {DOM Node || null}
*/
getSingleDescendant: function(node){
return this.getDescendant( node, null, false );
},
/**
* get node if it has no siblings of the same type. CSS equivalent is :only-of-type
*
* @param {DOM Node} rootNode
* @param {Array} tagNames
* @return {DOM Node || null}
*/
getSingleDescendantOfType: function(node, tagNames){
return this.getDescendant( node, tagNames, true );
},
/**
* get child node limited by presence of siblings - either CSS :only-of-type or :only-child
*
* @param {DOM Node} rootNode
* @param {Array} tagNames
* @return {DOM Node || null}
*/
getDescendant: function( node, tagNames, onlyOfType ){
var i = node.children.length,
countAll = 0,
countOfType = 0,
child,
out = null;
while(i--) {
child = node.children[i];
if(child.nodeType === 1) {
if(tagNames){
// count just only-of-type
if(this.hasTagName(child, tagNames)){
out = child;
countOfType++;
}
}else{
// count all elements
out = child;
countAll++;
}
}
}
if(onlyOfType === true){
return (countOfType === 1)? out : null;
}else{
return (countAll === 1)? out : null;
}
},
/**
* is a node one of a list of tags
*
* @param {DOM Node} rootNode
* @param {Array} tagNames
* @return {Boolean}
*/
hasTagName: function(node, tagNames){
var i = tagNames.length;
while(i--) {
if(node.tagName.toLowerCase() === tagNames[i]) {
return true;
}
}
return false;
},
/**
* abstracts DOM appendChild
*
* @param {DOM Node} node
* @param {DOM Node} childNode
* @return {DOM Node}
*/
appendChild: function(node, childNode){
return node.appendChild(childNode);
},
/**
* abstracts DOM removeChild
*
* @param {DOM Node} childNode
* @return {DOM Node || null}
*/
removeChild: function(childNode){
if (childNode.parentNode) {
return childNode.parentNode.removeChild(childNode);
}else{
return null;
}
},
/**
* abstracts DOM cloneNode
*
* @param {DOM Node} node
* @return {DOM Node}
*/
clone: function(node) {
var newNode = node.cloneNode(true);
newNode.removeAttribute('id');
return newNode;
},
/**
* gets the text of a node
*
* @param {DOM Node} node
* @return {String}
*/
getElementText: function( node ){
if(node && node.data){
return node.data;
}else{
return '';
}
},
/**
* gets the attributes of a node - ordered by sequence in html
*
* @param {DOM Node} node
* @return {Array}
*/
getOrderedAttributes: function( node ){
var nodeStr = node.outerHTML,
attrs = [];
for (var i = 0; i < node.attributes.length; i++) {
var attr = node.attributes[i];
attr.indexNum = nodeStr.indexOf(attr.name);
attrs.push( attr );
}
return attrs.sort( modules.utils.sortObjects( 'indexNum' ) );
},
/**
* decodes html entities in given text
*
* @param {DOM Document} doc
* @param String} text
* @return {String}
*/
decodeEntities: function( doc, text ){
//return text;
return doc.createTextNode( text ).nodeValue;
},
/**
* clones a DOM document
*
* @param {DOM Document} document
* @return {DOM Document}
*/
cloneDocument: function( document ){
var newNode,
newDocument = null;
if( this.canCloneDocument( document )){
newDocument = document.implementation.createHTMLDocument('');
newNode = newDocument.importNode( document.documentElement, true );
newDocument.replaceChild(newNode, newDocument.querySelector('html'));
}
return (newNode && newNode.nodeType && newNode.nodeType === 1)? newDocument : document;
},
/**
* can environment clone a DOM document
*
* @param {DOM Document} document
* @return {Boolean}
*/
canCloneDocument: function( document ){
return (document && document.importNode && document.implementation && document.implementation.createHTMLDocument);
},
/**
* get the child index of a node. Used to create a node path
*
* @param {DOM Node} node
* @return {Int}
*/
getChildIndex: function (node) {
var parent = node.parentNode,
i = -1,
child;
while (parent && (child = parent.childNodes[++i])){
if (child === node){
return i;
}
}
return -1;
},
/**
* get a node's path
*
* @param {DOM Node} node
* @return {Array}
*/
getNodePath: function (node) {
var parent = node.parentNode,
path = [],
index = this.getChildIndex(node);
if(parent && (path = this.getNodePath(parent))){
if(index > -1){
path.push(index);
}
}
return path;
},
/**
* get a node from a path.
*
* @param {DOM document} document
* @param {Array} path
* @return {DOM Node}
*/
getNodeByPath: function (document, path) {
var node = document.documentElement,
i = 0,
index;
while ((index = path[++i]) > -1){
node = node.childNodes[index];
}
return node;
},
/**
* get an array/nodeList of child nodes
*
* @param {DOM node} node
* @return {Array}
*/
getChildren: function( node ){
return node.children;
},
/**
* create a node
*
* @param {String} tagName
* @return {DOM node}
*/
createNode: function( tagName ){
return this.document.createElement(tagName);
},
/**
* create a node with text content
*
* @param {String} tagName
* @param {String} text
* @return {DOM node}
*/
createNodeWithText: function( tagName, text ){
var node = this.document.createElement(tagName);
node.innerHTML = text;
return node;
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,107 @@
/*
html
Extracts a HTML string from DOM nodes. Was created to get around the issue of not being able to exclude the content
of nodes with the 'data-include' attribute. DO NOT replace with functions such as innerHTML as it will break a
number of microformat include patterns.
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-node/master/license.txt
Dependencies utilities.js, domutils.js
*/
var Modules = (function (modules) {
modules.html = {
// elements which are self-closing
selfClosingElt: ['area', 'base', 'br', 'col', 'hr', 'img', 'input', 'link', 'meta', 'param', 'command', 'keygen', 'source'],
/**
* parse the html string from DOM Node
*
* @param {DOM Node} node
* @return {String}
*/
parse: function( node ){
var out = '',
j = 0;
// we do not want the outer container
if(node.childNodes && node.childNodes.length > 0){
for (j = 0; j < node.childNodes.length; j++) {
var text = this.walkTreeForHtml( node.childNodes[j] );
if(text !== undefined){
out += text;
}
}
}
return out;
},
/**
* walks the DOM tree parsing the html string from the nodes
*
* @param {DOM Document} doc
* @param {DOM Node} node
* @return {String}
*/
walkTreeForHtml: function( node ) {
var out = '',
j = 0;
// if node is a text node get its text
if(node.nodeType && node.nodeType === 3){
out += modules.domUtils.getElementText( node );
}
// exclude text which has been added with include pattern -
if(node.nodeType && node.nodeType === 1 && modules.domUtils.hasAttribute(node, 'data-include') === false){
// begin tag
out += '<' + node.tagName.toLowerCase();
// add attributes
var attrs = modules.domUtils.getOrderedAttributes(node);
for (j = 0; j < attrs.length; j++) {
out += ' ' + attrs[j].name + '=' + '"' + attrs[j].value + '"';
}
if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) === -1){
out += '>';
}
// get the text of the child nodes
if(node.childNodes && node.childNodes.length > 0){
for (j = 0; j < node.childNodes.length; j++) {
var text = this.walkTreeForHtml( node.childNodes[j] );
if(text !== undefined){
out += text;
}
}
}
// end tag
if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) > -1){
out += ' />';
}else{
out += '</' + node.tagName.toLowerCase() + '>';
}
}
return (out === '')? undefined : out;
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,481 @@
/*!
iso date
This module was built for the exact needs of parsing ISO dates to the microformats standard.
* Parses and builds ISO dates to the W3C note, HTML5 or RFC3339 profiles.
* Also allows for profile detection using 'auto'
* Outputs to the same level of specificity of date and time that was input
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
/**
* constructor
* parses text to find just the date element of an ISO date/time string i.e. 2008-05-01
*
* @param {String} dateString
* @param {String} format
* @return {String}
*/
modules.ISODate = function ( dateString, format ) {
this.clear();
this.format = (format)? format : 'auto'; // auto or W3C or RFC3339 or HTML5
this.setFormatSep();
// optional should be full iso date/time string
if(arguments[0]) {
this.parse(dateString, format);
}
};
modules.ISODate.prototype = {
/**
* clear all states
*
*/
clear: function(){
this.clearDate();
this.clearTime();
this.clearTimeZone();
this.setAutoProfileState();
},
/**
* clear date states
*
*/
clearDate: function(){
this.dY = -1;
this.dM = -1;
this.dD = -1;
this.dDDD = -1;
},
/**
* clear time states
*
*/
clearTime: function(){
this.tH = -1;
this.tM = -1;
this.tS = -1;
this.tD = -1;
},
/**
* clear timezone states
*
*/
clearTimeZone: function(){
this.tzH = -1;
this.tzM = -1;
this.tzPN = '+';
this.z = false;
},
/**
* resets the auto profile state
*
*/
setAutoProfileState: function(){
this.autoProfile = {
sep: 'T',
dsep: '-',
tsep: ':',
tzsep: ':',
tzZulu: 'Z'
};
},
/**
* parses text to find ISO date/time string i.e. 2008-05-01T15:45:19Z
*
* @param {String} dateString
* @param {String} format
* @return {String}
*/
parse: function( dateString, format ) {
this.clear();
var parts = [],
tzArray = [],
position = 0,
datePart = '',
timePart = '',
timeZonePart = '';
if(format){
this.format = format;
}
// discover date time separtor for auto profile
// Set to 'T' by default
if(dateString.indexOf('t') > -1) {
this.autoProfile.sep = 't';
}
if(dateString.indexOf('z') > -1) {
this.autoProfile.tzZulu = 'z';
}
if(dateString.indexOf('Z') > -1) {
this.autoProfile.tzZulu = 'Z';
}
if(dateString.toUpperCase().indexOf('T') === -1) {
this.autoProfile.sep = ' ';
}
dateString = dateString.toUpperCase().replace(' ','T');
// break on 'T' divider or space
if(dateString.indexOf('T') > -1) {
parts = dateString.split('T');
datePart = parts[0];
timePart = parts[1];
// zulu UTC
if(timePart.indexOf( 'Z' ) > -1) {
this.z = true;
}
// timezone
if(timePart.indexOf( '+' ) > -1 || timePart.indexOf( '-' ) > -1) {
tzArray = timePart.split( 'Z' ); // incase of incorrect use of Z
timePart = tzArray[0];
timeZonePart = tzArray[1];
// timezone
if(timePart.indexOf( '+' ) > -1 || timePart.indexOf( '-' ) > -1) {
position = 0;
if(timePart.indexOf( '+' ) > -1) {
position = timePart.indexOf( '+' );
} else {
position = timePart.indexOf( '-' );
}
timeZonePart = timePart.substring( position, timePart.length );
timePart = timePart.substring( 0, position );
}
}
} else {
datePart = dateString;
}
if(datePart !== '') {
this.parseDate( datePart );
if(timePart !== '') {
this.parseTime( timePart );
if(timeZonePart !== '') {
this.parseTimeZone( timeZonePart );
}
}
}
return this.toString( format );
},
/**
* parses text to find just the date element of an ISO date/time string i.e. 2008-05-01
*
* @param {String} dateString
* @param {String} format
* @return {String}
*/
parseDate: function( dateString, format ) {
this.clearDate();
var parts = [];
// discover timezone separtor for auto profile // default is ':'
if(dateString.indexOf('-') === -1) {
this.autoProfile.tsep = '';
}
// YYYY-DDD
parts = dateString.match( /(\d\d\d\d)-(\d\d\d)/ );
if(parts) {
if(parts[1]) {
this.dY = parts[1];
}
if(parts[2]) {
this.dDDD = parts[2];
}
}
if(this.dDDD === -1) {
// YYYY-MM-DD ie 2008-05-01 and YYYYMMDD ie 20080501
parts = dateString.match( /(\d\d\d\d)?-?(\d\d)?-?(\d\d)?/ );
if(parts[1]) {
this.dY = parts[1];
}
if(parts[2]) {
this.dM = parts[2];
}
if(parts[3]) {
this.dD = parts[3];
}
}
return this.toString(format);
},
/**
* parses text to find just the time element of an ISO date/time string i.e. 13:30:45
*
* @param {String} timeString
* @param {String} format
* @return {String}
*/
parseTime: function( timeString, format ) {
this.clearTime();
var parts = [];
// discover date separtor for auto profile // default is ':'
if(timeString.indexOf(':') === -1) {
this.autoProfile.tsep = '';
}
// finds timezone HH:MM:SS and HHMMSS ie 13:30:45, 133045 and 13:30:45.0135
parts = timeString.match( /(\d\d)?:?(\d\d)?:?(\d\d)?.?([0-9]+)?/ );
if(parts[1]) {
this.tH = parts[1];
}
if(parts[2]) {
this.tM = parts[2];
}
if(parts[3]) {
this.tS = parts[3];
}
if(parts[4]) {
this.tD = parts[4];
}
return this.toTimeString(format);
},
/**
* parses text to find just the time element of an ISO date/time string i.e. +08:00
*
* @param {String} timeString
* @param {String} format
* @return {String}
*/
parseTimeZone: function( timeString, format ) {
this.clearTimeZone();
var parts = [];
if(timeString.toLowerCase() === 'z'){
this.z = true;
// set case for z
this.autoProfile.tzZulu = (timeString === 'z')? 'z' : 'Z';
}else{
// discover timezone separtor for auto profile // default is ':'
if(timeString.indexOf(':') === -1) {
this.autoProfile.tzsep = '';
}
// finds timezone +HH:MM and +HHMM ie +13:30 and +1330
parts = timeString.match( /([\-\+]{1})?(\d\d)?:?(\d\d)?/ );
if(parts[1]) {
this.tzPN = parts[1];
}
if(parts[2]) {
this.tzH = parts[2];
}
if(parts[3]) {
this.tzM = parts[3];
}
}
this.tzZulu = 'z';
return this.toTimeString( format );
},
/**
* returns ISO date/time string in W3C Note, RFC 3339, HTML5, or auto profile
*
* @param {String} format
* @return {String}
*/
toString: function( format ) {
var output = '';
if(format){
this.format = format;
}
this.setFormatSep();
if(this.dY > -1) {
output = this.dY;
if(this.dM > 0 && this.dM < 13) {
output += this.dsep + this.dM;
if(this.dD > 0 && this.dD < 32) {
output += this.dsep + this.dD;
if(this.tH > -1 && this.tH < 25) {
output += this.sep + this.toTimeString( format );
}
}
}
if(this.dDDD > -1) {
output += this.dsep + this.dDDD;
}
} else if(this.tH > -1) {
output += this.toTimeString( format );
}
return output;
},
/**
* returns just the time string element of an ISO date/time
* in W3C Note, RFC 3339, HTML5, or auto profile
*
* @param {String} format
* @return {String}
*/
toTimeString: function( format ) {
var out = '';
if(format){
this.format = format;
}
this.setFormatSep();
// time can only be created with a full date
if(this.tH) {
if(this.tH > -1 && this.tH < 25) {
out += this.tH;
if(this.tM > -1 && this.tM < 61){
out += this.tsep + this.tM;
if(this.tS > -1 && this.tS < 61){
out += this.tsep + this.tS;
if(this.tD > -1){
out += '.' + this.tD;
}
}
}
// time zone offset
if(this.z) {
out += this.tzZulu;
} else {
if(this.tzH && this.tzH > -1 && this.tzH < 25) {
out += this.tzPN + this.tzH;
if(this.tzM > -1 && this.tzM < 61){
out += this.tzsep + this.tzM;
}
}
}
}
}
return out;
},
/**
* set the current profile to W3C Note, RFC 3339, HTML5, or auto profile
*
*/
setFormatSep: function() {
switch( this.format.toLowerCase() ) {
case 'rfc3339':
this.sep = 'T';
this.dsep = '';
this.tsep = '';
this.tzsep = '';
this.tzZulu = 'Z';
break;
case 'w3c':
this.sep = 'T';
this.dsep = '-';
this.tsep = ':';
this.tzsep = ':';
this.tzZulu = 'Z';
break;
case 'html5':
this.sep = ' ';
this.dsep = '-';
this.tsep = ':';
this.tzsep = ':';
this.tzZulu = 'Z';
break;
default:
// auto - defined by format of input string
this.sep = this.autoProfile.sep;
this.dsep = this.autoProfile.dsep;
this.tsep = this.autoProfile.tsep;
this.tzsep = this.autoProfile.tzsep;
this.tzZulu = this.autoProfile.tzZulu;
}
},
/**
* does current data contain a full date i.e. 2015-03-23
*
* @return {Boolean}
*/
hasFullDate: function() {
return(this.dY !== -1 && this.dM !== -1 && this.dD !== -1);
},
/**
* does current data contain a minimum date which is just a year number i.e. 2015
*
* @return {Boolean}
*/
hasDate: function() {
return(this.dY !== -1);
},
/**
* does current data contain a minimum time which is just a hour number i.e. 13
*
* @return {Boolean}
*/
hasTime: function() {
return(this.tH !== -1);
},
/**
* does current data contain a minimum timezone i.e. -1 || +1 || z
*
* @return {Boolean}
*/
hasTimeZone: function() {
return(this.tzH !== -1);
}
};
modules.ISODate.prototype.constructor = modules.ISODate;
return modules;
} (Modules || {}));

View File

@ -0,0 +1 @@
modules.livingStandard = '2015-09-25T12:26:04Z';

View File

@ -0,0 +1,29 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-adr'] = {
root: 'adr',
name: 'h-adr',
properties: {
'post-office-box': {},
'street-address': {},
'extended-address': {},
'locality': {},
'region': {},
'postal-code': {},
'country-name': {}
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,85 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-card'] = {
root: 'vcard',
name: 'h-card',
properties: {
'fn': {
'map': 'p-name'
},
'adr': {
'map': 'p-adr',
'uf': ['h-adr']
},
'agent': {
'uf': ['h-card']
},
'bday': {
'map': 'dt-bday'
},
'class': {},
'category': {
'map': 'p-category',
'relAlt': ['tag']
},
'email': {
'map': 'u-email'
},
'geo': {
'map': 'p-geo',
'uf': ['h-geo']
},
'key': {
'map': 'u-key'
},
'label': {},
'logo': {
'map': 'u-logo'
},
'mailer': {},
'honorific-prefix': {},
'given-name': {},
'additional-name': {},
'family-name': {},
'honorific-suffix': {},
'nickname': {},
'note': {}, // could be html i.e. e-note
'org': {},
'p-organization-name': {},
'p-organization-unit': {},
'photo': {
'map': 'u-photo'
},
'rev': {
'map': 'dt-rev'
},
'role': {},
'sequence': {},
'sort-string': {},
'sound': {
'map': 'u-sound'
},
'title': {
'map': 'p-job-title'
},
'tel': {},
'tz': {},
'uid': {
'map': 'u-uid'
},
'url': {
'map': 'u-url'
}
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,52 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-entry'] = {
root: 'hentry',
name: 'h-entry',
properties: {
'entry-title': {
'map': 'p-name'
},
'entry-summary': {
'map': 'p-summary'
},
'entry-content': {
'map': 'e-content'
},
'published': {
'map': 'dt-published'
},
'updated': {
'map': 'dt-updated'
},
'author': {
'uf': ['h-card']
},
'category': {
'map': 'p-category',
'relAlt': ['tag']
},
'geo': {
'map': 'p-geo',
'uf': ['h-geo']
},
'latitude': {},
'longitude': {},
'url': {
'map': 'u-url',
'relAlt': ['bookmark']
}
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,64 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-event'] = {
root: 'vevent',
name: 'h-event',
properties: {
'summary': {
'map': 'p-name'
},
'dtstart': {
'map': 'dt-start'
},
'dtend': {
'map': 'dt-end'
},
'description': {},
'url': {
'map': 'u-url'
},
'category': {
'map': 'p-category',
'relAlt': ['tag']
},
'location': {
'uf': ['h-card']
},
'geo': {
'uf': ['h-geo']
},
'latitude': {},
'longitude': {},
'duration': {
'map': 'dt-duration'
},
'contact': {
'uf': ['h-card']
},
'organizer': {
'uf': ['h-card']},
'attendee': {
'uf': ['h-card']},
'uid': {
'map': 'u-uid'
},
'attach': {
'map': 'u-attach'
},
'status': {},
'rdate': {},
'rrule': {}
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,36 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-feed'] = {
root: 'hfeed',
name: 'h-feed',
properties: {
'category': {
'map': 'p-category',
'relAlt': ['tag']
},
'summary': {
'map': 'p-summary'
},
'author': {
'uf': ['h-card']
},
'url': {
'map': 'u-url'
},
'photo': {
'map': 'u-photo'
},
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,22 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-geo'] = {
root: 'geo',
name: 'h-geo',
properties: {
'latitude': {},
'longitude': {}
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,30 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-item'] = {
root: 'item',
name: 'h-item',
subTree: false,
properties: {
'fn': {
'map': 'p-name'
},
'url': {
'map': 'u-url'
},
'photo': {
'map': 'u-photo'
}
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,41 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-listing'] = {
root: 'hlisting',
name: 'h-listing',
properties: {
'version': {},
'lister': {
'uf': ['h-card']
},
'dtlisted': {
'map': 'dt-listed'
},
'dtexpired': {
'map': 'dt-expired'
},
'location': {},
'price': {},
'item': {
'uf': ['h-card','a-adr','h-geo']
},
'summary': {
'map': 'p-name'
},
'description': {
'map': 'e-description'
},
'listing': {}
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,42 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-news'] = {
root: 'hnews',
name: 'h-news',
properties: {
'entry': {
'uf': ['h-entry']
},
'geo': {
'uf': ['h-geo']
},
'latitude': {},
'longitude': {},
'source-org': {
'uf': ['h-card']
},
'dateline': {
'uf': ['h-card']
},
'item-license': {
'map': 'u-item-license'
},
'principles': {
'map': 'u-principles',
'relAlt': ['principles']
}
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,24 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-org'] = {
root: 'h-x-org', // drop this from v1 as it causes issue with fn org hcard pattern
name: 'h-org',
childStructure: true,
properties: {
'organization-name': {},
'organization-unit': {}
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,49 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-product'] = {
root: 'hproduct',
name: 'h-product',
properties: {
'brand': {
'uf': ['h-card']
},
'category': {
'map': 'p-category',
'relAlt': ['tag']
},
'price': {},
'description': {
'map': 'e-description'
},
'fn': {
'map': 'p-name'
},
'photo': {
'map': 'u-photo'
},
'url': {
'map': 'u-url'
},
'review': {
'uf': ['h-review', 'h-review-aggregate']
},
'listing': {
'uf': ['h-listing']
},
'identifier': {
'map': 'u-identifier'
}
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,47 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-recipe'] = {
root: 'hrecipe',
name: 'h-recipe',
properties: {
'fn': {
'map': 'p-name'
},
'ingredient': {
'map': 'e-ingredient'
},
'yield': {},
'instructions': {
'map': 'e-instructions'
},
'duration': {
'map': 'dt-duration'
},
'photo': {
'map': 'u-photo'
},
'summary': {},
'author': {
'uf': ['h-card']
},
'published': {
'map': 'dt-published'
},
'nutrition': {},
'category': {
'map': 'p-category',
'relAlt': ['tag']
},
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,34 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-resume'] = {
root: 'hresume',
name: 'h-resume',
properties: {
'summary': {},
'contact': {
'uf': ['h-card']
},
'education': {
'uf': ['h-card', 'h-event']
},
'experience': {
'uf': ['h-card', 'h-event']
},
'skill': {},
'affiliation': {
'uf': ['h-card']
}
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,40 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-review-aggregate'] = {
root: 'hreview-aggregate',
name: 'h-review-aggregate',
properties: {
'summary': {
'map': 'p-name'
},
'item': {
'map': 'p-item',
'uf': ['h-item', 'h-geo', 'h-adr', 'h-card', 'h-event', 'h-product']
},
'rating': {},
'average': {},
'best': {},
'worst': {},
'count': {},
'votes': {},
'category': {
'map': 'p-category',
'relAlt': ['tag']
},
'url': {
'map': 'u-url',
'relAlt': ['self', 'bookmark']
}
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,46 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-review'] = {
root: 'hreview',
name: 'h-review',
properties: {
'summary': {
'map': 'p-name'
},
'description': {
'map': 'e-description'
},
'item': {
'map': 'p-item',
'uf': ['h-item', 'h-geo', 'h-adr', 'h-card', 'h-event', 'h-product']
},
'reviewer': {
'uf': ['h-card']
},
'dtreviewer': {
'map': 'dt-reviewer'
},
'rating': {},
'best': {},
'worst': {},
'category': {
'map': 'p-category',
'relAlt': ['tag']
},
'url': {
'map': 'u-url',
'relAlt': ['self', 'bookmark']
}
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,47 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.rels = {
// xfn
'friend': [ 'yes','external'],
'acquaintance': [ 'yes','external'],
'contact': [ 'yes','external'],
'met': [ 'yes','external'],
'co-worker': [ 'yes','external'],
'colleague': [ 'yes','external'],
'co-resident': [ 'yes','external'],
'neighbor': [ 'yes','external'],
'child': [ 'yes','external'],
'parent': [ 'yes','external'],
'sibling': [ 'yes','external'],
'spouse': [ 'yes','external'],
'kin': [ 'yes','external'],
'muse': [ 'yes','external'],
'crush': [ 'yes','external'],
'date': [ 'yes','external'],
'sweetheart': [ 'yes','external'],
'me': [ 'yes','external'],
// other rel=*
'license': [ 'yes','yes'],
'nofollow': [ 'no','external'],
'tag': [ 'no','yes'],
'self': [ 'no','external'],
'bookmark': [ 'no','external'],
'author': [ 'no','external'],
'home': [ 'no','external'],
'directory': [ 'no','external'],
'enclosure': [ 'no','external'],
'pronunciation': [ 'no','external'],
'payment': [ 'no','external'],
'principles': [ 'no','external']
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,439 @@
/*!
Parser implied
All the functions that deal with microformats implied rules
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
Dependencies dates.js, domutils.js, html.js, isodate,js, text.js, utilities.js, url.js
*/
var Modules = (function (modules) {
// check parser module is loaded
if(modules.Parser){
/**
* applies "implied rules" microformat output structure i.e. feed-title, name, photo, url and date
*
* @param {DOM Node} node
* @param {Object} uf (microformat output structure)
* @param {Object} parentClasses (classes structure)
* @param {Boolean} impliedPropertiesByVersion
* @return {Object}
*/
modules.Parser.prototype.impliedRules = function(node, uf, parentClasses) {
var typeVersion = (uf.typeVersion)? uf.typeVersion: 'v2';
// TEMP: override to allow v1 implied properties while spec changes
if(this.options.impliedPropertiesByVersion === false){
typeVersion = 'v2';
}
if(node && uf && uf.properties) {
uf = this.impliedBackwardComp( node, uf, parentClasses );
if(typeVersion === 'v2'){
uf = this.impliedhFeedTitle( uf );
uf = this.impliedName( node, uf );
uf = this.impliedPhoto( node, uf );
uf = this.impliedUrl( node, uf );
}
uf = this.impliedValue( node, uf, parentClasses );
uf = this.impliedDate( uf );
// TEMP: flagged while spec changes are put forward
if(this.options.parseLatLonGeo === true){
uf = this.impliedGeo( uf );
}
}
return uf;
};
/**
* apply implied name rule
*
* @param {DOM Node} node
* @param {Object} uf
* @return {Object}
*/
modules.Parser.prototype.impliedName = function(node, uf) {
// implied name rule
/*
img.h-x[alt] <img class="h-card" src="glenn.htm" alt="Glenn Jones"></a>
area.h-x[alt] <area class="h-card" href="glenn.htm" alt="Glenn Jones"></area>
abbr.h-x[title] <abbr class="h-card" title="Glenn Jones"GJ</abbr>
.h-x>img:only-child[alt]:not[.h-*] <div class="h-card"><a src="glenn.htm" alt="Glenn Jones"></a></div>
.h-x>area:only-child[alt]:not[.h-*] <div class="h-card"><area href="glenn.htm" alt="Glenn Jones"></area></div>
.h-x>abbr:only-child[title] <div class="h-card"><abbr title="Glenn Jones">GJ</abbr></div>
.h-x>:only-child>img:only-child[alt]:not[.h-*] <div class="h-card"><span><img src="jane.html" alt="Jane Doe"/></span></div>
.h-x>:only-child>area:only-child[alt]:not[.h-*] <div class="h-card"><span><area href="jane.html" alt="Jane Doe"></area></span></div>
.h-x>:only-child>abbr:only-child[title] <div class="h-card"><span><abbr title="Jane Doe">JD</abbr></span></div>
*/
var name,
value;
if(!uf.properties.name) {
value = this.getImpliedProperty(node, ['img', 'area', 'abbr'], this.getNameAttr);
var textFormat = this.options.textFormat;
// if no value for tags/properties use text
if(!value) {
name = [modules.text.parse(this.document, node, textFormat)];
}else{
name = [modules.text.parseText(this.document, value, textFormat)];
}
if(name && name[0] !== ''){
uf.properties.name = name;
}
}
return uf;
};
/**
* apply implied photo rule
*
* @param {DOM Node} node
* @param {Object} uf
* @return {Object}
*/
modules.Parser.prototype.impliedPhoto = function(node, uf) {
// implied photo rule
/*
img.h-x[src] <img class="h-card" alt="Jane Doe" src="jane.jpeg"/>
object.h-x[data] <object class="h-card" data="jane.jpeg"/>Jane Doe</object>
.h-x>img[src]:only-of-type:not[.h-*] <div class="h-card"><img alt="Jane Doe" src="jane.jpeg"/></div>
.h-x>object[data]:only-of-type:not[.h-*] <div class="h-card"><object data="jane.jpeg"/>Jane Doe</object></div>
.h-x>:only-child>img[src]:only-of-type:not[.h-*] <div class="h-card"><span><img alt="Jane Doe" src="jane.jpeg"/></span></div>
.h-x>:only-child>object[data]:only-of-type:not[.h-*] <div class="h-card"><span><object data="jane.jpeg"/>Jane Doe</object></span></div>
*/
var value;
if(!uf.properties.photo) {
value = this.getImpliedProperty(node, ['img', 'object'], this.getPhotoAttr);
if(value) {
// relative to absolute URL
if(value && value !== '' && this.options.baseUrl !== '' && value.indexOf('://') === -1) {
value = modules.url.resolve(value, this.options.baseUrl);
}
uf.properties.photo = [modules.utils.trim(value)];
}
}
return uf;
};
/**
* apply implied URL rule
*
* @param {DOM Node} node
* @param {Object} uf
* @return {Object}
*/
modules.Parser.prototype.impliedUrl = function(node, uf) {
// implied URL rule
/*
a.h-x[href] <a class="h-card" href="glenn.html">Glenn</a>
area.h-x[href] <area class="h-card" href="glenn.html">Glenn</area>
.h-x>a[href]:only-of-type:not[.h-*] <div class="h-card" ><a href="glenn.html">Glenn</a><p>...</p></div>
.h-x>area[href]:only-of-type:not[.h-*] <div class="h-card" ><area href="glenn.html">Glenn</area><p>...</p></div>
*/
var value;
if(!uf.properties.url) {
value = this.getImpliedProperty(node, ['a', 'area'], this.getURLAttr);
if(value) {
// relative to absolute URL
if(value && value !== '' && this.options.baseUrl !== '' && value.indexOf('://') === -1) {
value = modules.url.resolve(value, this.options.baseUrl);
}
uf.properties.url = [modules.utils.trim(value)];
}
}
return uf;
};
/**
* apply implied date rule - if there is a time only property try to concat it with any date property
*
* @param {DOM Node} node
* @param {Object} uf
* @return {Object}
*/
modules.Parser.prototype.impliedDate = function(uf) {
// implied date rule
// http://microformats.org/wiki/value-class-pattern#microformats2_parsers
// http://microformats.org/wiki/microformats2-parsing-issues#implied_date_for_dt_properties_both_mf2_and_backcompat
var newDate;
if(uf.times.length > 0 && uf.dates.length > 0) {
newDate = modules.dates.dateTimeUnion(uf.dates[0][1], uf.times[0][1], this.options.dateFormat);
uf.properties[this.removePropPrefix(uf.times[0][0])][0] = newDate.toString(this.options.dateFormat);
}
// clean-up object
delete uf.times;
delete uf.dates;
return uf;
};
/**
* get an implied property value from pre-defined tag/attriubte combinations
*
* @param {DOM Node} node
* @param {String} tagList (Array of tags from which an implied value can be pulled)
* @param {String} getAttrFunction (Function which can extract implied value)
* @return {String || null}
*/
modules.Parser.prototype.getImpliedProperty = function(node, tagList, getAttrFunction) {
// i.e. img.h-card
var value = getAttrFunction(node),
descendant,
child;
if(!value) {
// i.e. .h-card>img:only-of-type:not(.h-card)
descendant = modules.domUtils.getSingleDescendantOfType( node, tagList);
if(descendant && this.hasHClass(descendant) === false){
value = getAttrFunction(descendant);
}
if(node.children.length > 0 ){
// i.e. .h-card>:only-child>img:only-of-type:not(.h-card)
child = modules.domUtils.getSingleDescendant(node);
if(child && this.hasHClass(child) === false){
descendant = modules.domUtils.getSingleDescendantOfType(child, tagList);
if(descendant && this.hasHClass(descendant) === false){
value = getAttrFunction(descendant);
}
}
}
}
return value;
};
/**
* get an implied name value from a node
*
* @param {DOM Node} node
* @return {String || null}
*/
modules.Parser.prototype.getNameAttr = function(node) {
var value = modules.domUtils.getAttrValFromTagList(node, ['img','area'], 'alt');
if(!value) {
value = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title');
}
return value;
};
/**
* get an implied photo value from a node
*
* @param {DOM Node} node
* @return {String || null}
*/
modules.Parser.prototype.getPhotoAttr = function(node) {
var value = modules.domUtils.getAttrValFromTagList(node, ['img'], 'src');
if(!value && modules.domUtils.hasAttributeValue(node, 'class', 'include') === false) {
value = modules.domUtils.getAttrValFromTagList(node, ['object'], 'data');
}
return value;
};
/**
* get an implied photo value from a node
*
* @param {DOM Node} node
* @return {String || null}
*/
modules.Parser.prototype.getURLAttr = function(node) {
var value = null;
if(modules.domUtils.hasAttributeValue(node, 'class', 'include') === false){
value = modules.domUtils.getAttrValFromTagList(node, ['a'], 'href');
if(!value) {
value = modules.domUtils.getAttrValFromTagList(node, ['area'], 'href');
}
}
return value;
};
/**
*
*
* @param {DOM Node} node
* @param {Object} uf
* @return {Object}
*/
modules.Parser.prototype.impliedValue = function(node, uf, parentClasses){
// intersection of implied name and implied value rules
if(uf.properties.name) {
if(uf.value && parentClasses.root.length > 0 && parentClasses.properties.length === 1){
uf = this.getAltValue(uf, parentClasses.properties[0][0], 'p-name', uf.properties.name[0]);
}
}
// intersection of implied URL and implied value rules
if(uf.properties.url) {
if(parentClasses && parentClasses.root.length === 1 && parentClasses.properties.length === 1){
uf = this.getAltValue(uf, parentClasses.properties[0][0], 'u-url', uf.properties.url[0]);
}
}
// apply alt value
if(uf.altValue !== null){
uf.value = uf.altValue.value;
}
delete uf.altValue;
return uf;
};
/**
* get alt value based on rules about parent property prefix
*
* @param {Object} uf
* @param {String} parentPropertyName
* @param {String} propertyName
* @param {String} value
* @return {Object}
*/
modules.Parser.prototype.getAltValue = function(uf, parentPropertyName, propertyName, value){
if(uf.value && !uf.altValue){
// first p-name of the h-* child
if(modules.utils.startWith(parentPropertyName,'p-') && propertyName === 'p-name'){
uf.altValue = {name: propertyName, value: value};
}
// if it's an e-* property element
if(modules.utils.startWith(parentPropertyName,'e-') && modules.utils.startWith(propertyName,'e-')){
uf.altValue = {name: propertyName, value: value};
}
// if it's an u-* property element
if(modules.utils.startWith(parentPropertyName,'u-') && propertyName === 'u-url'){
uf.altValue = {name: propertyName, value: value};
}
}
return uf;
};
/**
* if a h-feed does not have a title use the title tag of a page
*
* @param {Object} uf
* @return {Object}
*/
modules.Parser.prototype.impliedhFeedTitle = function( uf ){
if(uf.type && uf.type.indexOf('h-feed') > -1){
// has no name property
if(uf.properties.name === undefined || uf.properties.name[0] === '' ){
// use the text from the title tag
var title = modules.domUtils.querySelector(this.document, 'title');
if(title){
uf.properties.name = [modules.domUtils.textContent(title)];
}
}
}
return uf;
};
/**
* implied Geo from pattern <abbr class="p-geo" title="37.386013;-122.082932">
*
* @param {Object} uf
* @return {Object}
*/
modules.Parser.prototype.impliedGeo = function( uf ){
var geoPair,
parts,
longitude,
latitude,
valid = true;
if(uf.type && uf.type.indexOf('h-geo') > -1){
// has no latitude or longitude property
if(uf.properties.latitude === undefined || uf.properties.longitude === undefined ){
geoPair = (uf.properties.name)? uf.properties.name[0] : null;
geoPair = (!geoPair && uf.properties.value)? uf.properties.value : geoPair;
if(geoPair){
// allow for the use of a ';' as in microformats and also ',' as in Geo URL
geoPair = geoPair.replace(';',',');
// has sep char
if(geoPair.indexOf(',') > -1 ){
parts = geoPair.split(',');
// only correct if we have two or more parts
if(parts.length > 1){
// latitude no value outside the range -90 or 90
latitude = parseFloat( parts[0] );
if(modules.utils.isNumber(latitude) && latitude > 90 || latitude < -90){
valid = false;
}
// longitude no value outside the range -180 to 180
longitude = parseFloat( parts[1] );
if(modules.utils.isNumber(longitude) && longitude > 180 || longitude < -180){
valid = false;
}
if(valid){
uf.properties.latitude = [latitude];
uf.properties.longitude = [longitude];
}
}
}
}
}
}
return uf;
};
/**
* if a backwards compat built structure has no properties add name through this.impliedName
*
* @param {Object} uf
* @return {Object}
*/
modules.Parser.prototype.impliedBackwardComp = function(node, uf, parentClasses){
// look for pattern in parent classes like "p-geo h-geo"
// these are structures built from backwards compat parsing of geo
if(parentClasses.root.length === 1 && parentClasses.properties.length === 1) {
if(parentClasses.root[0].replace('h-','') === this.removePropPrefix(parentClasses.properties[0][0])) {
// if microformat has no properties apply the impliedName rule to get value from containing node
// this will get value from html such as <abbr class="geo" title="30.267991;-97.739568">Brighton</abbr>
if( modules.utils.hasProperties(uf.properties) === false ){
uf = this.impliedName( node, uf );
}
}
}
return uf;
};
}
return modules;
} (Modules || {}));

View File

@ -0,0 +1,150 @@
/*!
Parser includes
All the functions that deal with microformats v1 include rules
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
Dependencies dates.js, domutils.js, html.js, isodate,js, text.js, utilities.js
*/
var Modules = (function (modules) {
// check parser module is loaded
if(modules.Parser){
/**
* appends clones of include Nodes into the DOM structure
*
* @param {DOM node} rootNode
*/
modules.Parser.prototype.addIncludes = function(rootNode) {
this.addAttributeIncludes(rootNode, 'itemref');
this.addAttributeIncludes(rootNode, 'headers');
this.addClassIncludes(rootNode);
};
/**
* appends clones of include Nodes into the DOM structure for attribute based includes
*
* @param {DOM node} rootNode
* @param {String} attributeName
*/
modules.Parser.prototype.addAttributeIncludes = function(rootNode, attributeName) {
var arr,
idList,
i,
x,
z,
y;
arr = modules.domUtils.getNodesByAttribute(rootNode, attributeName);
x = 0;
i = arr.length;
while(x < i) {
idList = modules.domUtils.getAttributeList(arr[x], attributeName);
if(idList) {
z = 0;
y = idList.length;
while(z < y) {
this.apppendInclude(arr[x], idList[z]);
z++;
}
}
x++;
}
};
/**
* appends clones of include Nodes into the DOM structure for class based includes
*
* @param {DOM node} rootNode
*/
modules.Parser.prototype.addClassIncludes = function(rootNode) {
var id,
arr,
x = 0,
i;
arr = modules.domUtils.getNodesByAttributeValue(rootNode, 'class', 'include');
i = arr.length;
while(x < i) {
id = modules.domUtils.getAttrValFromTagList(arr[x], ['a'], 'href');
if(!id) {
id = modules.domUtils.getAttrValFromTagList(arr[x], ['object'], 'data');
}
this.apppendInclude(arr[x], id);
x++;
}
};
/**
* appends a clone of an include into another Node using Id
*
* @param {DOM node} rootNode
* @param {Stringe} id
*/
modules.Parser.prototype.apppendInclude = function(node, id){
var include,
clone;
id = modules.utils.trim(id.replace('#', ''));
include = modules.domUtils.getElementById(this.document, id);
if(include) {
clone = modules.domUtils.clone(include);
this.markIncludeChildren(clone);
modules.domUtils.appendChild(node, clone);
}
};
/**
* adds an attribute marker to all the child microformat roots
*
* @param {DOM node} rootNode
*/
modules.Parser.prototype.markIncludeChildren = function(rootNode) {
var arr,
x,
i;
// loop the array and add the attribute
arr = this.findRootNodes(rootNode);
x = 0;
i = arr.length;
modules.domUtils.setAttribute(rootNode, 'data-include', 'true');
modules.domUtils.setAttribute(rootNode, 'style', 'display:none');
while(x < i) {
modules.domUtils.setAttribute(arr[x], 'data-include', 'true');
x++;
}
};
/**
* removes all appended include clones from DOM
*
* @param {DOM node} rootNode
*/
modules.Parser.prototype.removeIncludes = function(rootNode){
var arr,
i;
// remove all the items that were added as includes
arr = modules.domUtils.getNodesByAttribute(rootNode, 'data-include');
i = arr.length;
while(i--) {
modules.domUtils.removeChild(rootNode,arr[i]);
}
};
}
return modules;
} (Modules || {}));

View File

@ -0,0 +1,200 @@
/*!
Parser rels
All the functions that deal with microformats v2 rel structures
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
Dependencies dates.js, domutils.js, html.js, isodate,js, text.js, utilities.js, url.js
*/
var Modules = (function (modules) {
// check parser module is loaded
if(modules.Parser){
/**
* finds rel=* structures
*
* @param {DOM node} rootNode
* @return {Object}
*/
modules.Parser.prototype.findRels = function(rootNode) {
var out = {
'items': [],
'rels': {},
'rel-urls': {}
},
x,
i,
y,
z,
relList,
items,
item,
value,
arr;
arr = modules.domUtils.getNodesByAttribute(rootNode, 'rel');
x = 0;
i = arr.length;
while(x < i) {
relList = modules.domUtils.getAttribute(arr[x], 'rel');
if(relList) {
items = relList.split(' ');
// add rels
z = 0;
y = items.length;
while(z < y) {
item = modules.utils.trim(items[z]);
// get rel value
value = modules.domUtils.getAttrValFromTagList(arr[x], ['a', 'area'], 'href');
if(!value) {
value = modules.domUtils.getAttrValFromTagList(arr[x], ['link'], 'href');
}
// create the key
if(!out.rels[item]) {
out.rels[item] = [];
}
if(typeof this.options.baseUrl === 'string' && typeof value === 'string') {
var resolved = modules.url.resolve(value, this.options.baseUrl);
// do not add duplicate rels - based on resolved URLs
if(out.rels[item].indexOf(resolved) === -1){
out.rels[item].push( resolved );
}
}
z++;
}
var url = null;
if(modules.domUtils.hasAttribute(arr[x], 'href')){
url = modules.domUtils.getAttribute(arr[x], 'href');
if(url){
url = modules.url.resolve(url, this.options.baseUrl );
}
}
// add to rel-urls
var relUrl = this.getRelProperties(arr[x]);
relUrl.rels = items;
// // do not add duplicate rel-urls - based on resolved URLs
if(url && out['rel-urls'][url] === undefined){
out['rel-urls'][url] = relUrl;
}
}
x++;
}
return out;
};
/**
* gets the properties of a rel=*
*
* @param {DOM node} node
* @return {Object}
*/
modules.Parser.prototype.getRelProperties = function(node){
var obj = {};
if(modules.domUtils.hasAttribute(node, 'media')){
obj.media = modules.domUtils.getAttribute(node, 'media');
}
if(modules.domUtils.hasAttribute(node, 'type')){
obj.type = modules.domUtils.getAttribute(node, 'type');
}
if(modules.domUtils.hasAttribute(node, 'hreflang')){
obj.hreflang = modules.domUtils.getAttribute(node, 'hreflang');
}
if(modules.domUtils.hasAttribute(node, 'title')){
obj.title = modules.domUtils.getAttribute(node, 'title');
}
if(modules.utils.trim(this.getPValue(node, false)) !== ''){
obj.text = this.getPValue(node, false);
}
return obj;
};
/**
* finds any alt rel=* mappings for a given node/microformat
*
* @param {DOM node} node
* @param {String} ufName
* @return {String || undefined}
*/
modules.Parser.prototype.findRelImpied = function(node, ufName) {
var out,
map,
i;
map = this.getMapping(ufName);
if(map) {
for(var key in map.properties) {
if (map.properties.hasOwnProperty(key)) {
var prop = map.properties[key],
propName = (prop.map) ? prop.map : 'p-' + key,
relCount = 0;
// is property an alt rel=* mapping
if(prop.relAlt && modules.domUtils.hasAttribute(node, 'rel')) {
i = prop.relAlt.length;
while(i--) {
if(modules.domUtils.hasAttributeValue(node, 'rel', prop.relAlt[i])) {
relCount++;
}
}
if(relCount === prop.relAlt.length) {
out = propName;
}
}
}
}
}
return out;
};
/**
* returns whether a node or its children has rel=* microformat
*
* @param {DOM node} node
* @return {Boolean}
*/
modules.Parser.prototype.hasRel = function(node) {
return (this.countRels(node) > 0);
};
/**
* returns the number of rel=* microformats
*
* @param {DOM node} node
* @return {Int}
*/
modules.Parser.prototype.countRels = function(node) {
if(node){
return modules.domUtils.getNodesByAttribute(node, 'rel').length;
}
return 0;
};
}
return modules;
} (Modules || {}));

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,151 @@
/*
text
Extracts text string from DOM nodes. Was created to extract text in a whitespace-normalized form.
It works like a none-CSS aware version of IE's innerText function. DO NOT replace this module
with functions such as textContent as it will reduce the quality of data provided to the API user.
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
Dependencies utilities.js, domutils.js
*/
var Modules = (function (modules) {
modules.text = {
// normalised or whitespace or whitespacetrimmed
textFormat: 'whitespacetrimmed',
// block level tags, used to add line returns
blockLevelTags: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'hr', 'pre', 'table',
'address', 'article', 'aside', 'blockquote', 'caption', 'col', 'colgroup', 'dd', 'div',
'dt', 'dir', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'header', 'hgroup', 'hr',
'li', 'map', 'menu', 'nav', 'optgroup', 'option', 'section', 'tbody', 'testarea',
'tfoot', 'th', 'thead', 'tr', 'td', 'ul', 'ol', 'dl', 'details'],
// tags to exclude
excludeTags: ['noframe', 'noscript', 'template', 'script', 'style', 'frames', 'frameset'],
/**
* parses the text from the DOM Node
*
* @param {DOM Node} node
* @param {String} textFormat
* @return {String}
*/
parse: function(doc, node, textFormat){
var out;
this.textFormat = (textFormat)? textFormat : this.textFormat;
if(this.textFormat === 'normalised'){
out = this.walkTreeForText( node );
if(out !== undefined){
return this.normalise( doc, out );
}else{
return '';
}
}else{
return this.formatText( doc, modules.domUtils.textContent(node), this.textFormat );
}
},
/**
* parses the text from a html string
*
* @param {DOM Document} doc
* @param {String} text
* @param {String} textFormat
* @return {String}
*/
parseText: function( doc, text, textFormat ){
var node = modules.domUtils.createNodeWithText( 'div', text );
return this.parse( doc, node, textFormat );
},
/**
* parses the text from a html string - only for whitespace or whitespacetrimmed formats
*
* @param {String} text
* @param {String} textFormat
* @return {String}
*/
formatText: function( doc, text, textFormat ){
this.textFormat = (textFormat)? textFormat : this.textFormat;
if(text){
var out = '',
regex = /(<([^>]+)>)/ig;
out = text.replace(regex, '');
if(this.textFormat === 'whitespacetrimmed') {
out = modules.utils.trimWhitespace( out );
}
//return entities.decode( out, 2 );
return modules.domUtils.decodeEntities( doc, out );
}else{
return '';
}
},
/**
* normalises whitespace in given text
*
* @param {String} text
* @return {String}
*/
normalise: function( doc, text ){
text = text.replace( /&nbsp;/g, ' ') ; // exchanges html entity for space into space char
text = modules.utils.collapseWhiteSpace( text ); // removes linefeeds, tabs and addtional spaces
text = modules.domUtils.decodeEntities( doc, text ); // decode HTML entities
text = text.replace( '', '-' ); // correct dash decoding
return modules.utils.trim( text );
},
/**
* walks DOM tree parsing the text from DOM Nodes
*
* @param {DOM Node} node
* @return {String}
*/
walkTreeForText: function( node ) {
var out = '',
j = 0;
if(node.tagName && this.excludeTags.indexOf( node.tagName.toLowerCase() ) > -1){
return out;
}
// if node is a text node get its text
if(node.nodeType && node.nodeType === 3){
out += modules.domUtils.getElementText( node );
}
// get the text of the child nodes
if(node.childNodes && node.childNodes.length > 0){
for (j = 0; j < node.childNodes.length; j++) {
var text = this.walkTreeForText( node.childNodes[j] );
if(text !== undefined){
out += text;
}
}
}
// if it's a block level tag add an additional space at the end
if(node.tagName && this.blockLevelTags.indexOf( node.tagName.toLowerCase() ) !== -1){
out += ' ';
}
return (out === '')? undefined : out ;
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,73 @@
/*
url
Where possible use the modern window.URL API if its not available use the DOMParser method.
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.url = {
/**
* creates DOM objects needed to resolve URLs
*/
init: function(){
//this._domParser = new DOMParser();
this._domParser = modules.domUtils.getDOMParser();
// do not use a head tag it does not work with IE9
this._html = '<base id="base" href=""></base><a id="link" href=""></a>';
this._nodes = this._domParser.parseFromString( this._html, 'text/html' );
this._baseNode = modules.domUtils.getElementById(this._nodes,'base');
this._linkNode = modules.domUtils.getElementById(this._nodes,'link');
},
/**
* resolves url to absolute version using baseUrl
*
* @param {String} url
* @param {String} baseUrl
* @return {String}
*/
resolve: function(url, baseUrl) {
// use modern URL web API where we can
if(modules.utils.isString(url) && modules.utils.isString(baseUrl) && url.indexOf('://') === -1){
// this try catch is required as IE has an URL object but no constuctor support
// http://glennjones.net/articles/the-problem-with-window-url
try {
var resolved = new URL(url, baseUrl).toString();
// deal with early Webkit not throwing an error - for Safari
if(resolved === '[object URL]'){
resolved = URI.resolve(baseUrl, url);
}
return resolved;
}catch(e){
// otherwise fallback to DOM
if(this._domParser === undefined){
this.init();
}
// do not use setAttribute it does not work with IE9
this._baseNode.href = baseUrl;
this._linkNode.href = url;
// dont use getAttribute as it returns orginal value not resolved
return this._linkNode.href;
}
}else{
if(modules.utils.isString(url)){
return url;
}
return '';
}
},
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1,206 @@
/*
Utilities
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.utils = {
/**
* is the object a string
*
* @param {Object} obj
* @return {Boolean}
*/
isString: function( obj ) {
return typeof( obj ) === 'string';
},
/**
* is the object a number
*
* @param {Object} obj
* @return {Boolean}
*/
isNumber: function( obj ) {
return !isNaN(parseFloat( obj )) && isFinite( obj );
},
/**
* is the object an array
*
* @param {Object} obj
* @return {Boolean}
*/
isArray: function( obj ) {
return obj && !( obj.propertyIsEnumerable( 'length' ) ) && typeof obj === 'object' && typeof obj.length === 'number';
},
/**
* is the object a function
*
* @param {Object} obj
* @return {Boolean}
*/
isFunction: function(obj) {
return !!(obj && obj.constructor && obj.call && obj.apply);
},
/**
* does the text start with a test string
*
* @param {String} text
* @param {String} test
* @return {Boolean}
*/
startWith: function( text, test ) {
return(text.indexOf(test) === 0);
},
/**
* removes spaces at front and back of text
*
* @param {String} text
* @return {String}
*/
trim: function( text ) {
if(text && this.isString(text)){
return (text.trim())? text.trim() : text.replace(/^\s+|\s+$/g, '');
}else{
return '';
}
},
/**
* replaces a character in text
*
* @param {String} text
* @param {Int} index
* @param {String} character
* @return {String}
*/
replaceCharAt: function( text, index, character ) {
if(text && text.length > index){
return text.substr(0, index) + character + text.substr(index+character.length);
}else{
return text;
}
},
/**
* removes whitespace, tabs and returns from start and end of text
*
* @param {String} text
* @return {String}
*/
trimWhitespace: function( text ){
if(text && text.length){
var i = text.length,
x = 0;
// turn all whitespace chars at end into spaces
while (i--) {
if(this.isOnlyWhiteSpace(text[i])){
text = this.replaceCharAt( text, i, ' ' );
}else{
break;
}
}
// turn all whitespace chars at start into spaces
i = text.length;
while (x < i) {
if(this.isOnlyWhiteSpace(text[x])){
text = this.replaceCharAt( text, i, ' ' );
}else{
break;
}
x++;
}
}
return this.trim(text);
},
/**
* does text only contain whitespace characters
*
* @param {String} text
* @return {Boolean}
*/
isOnlyWhiteSpace: function( text ){
return !(/[^\t\n\r ]/.test( text ));
},
/**
* removes whitespace from text (leaves a single space)
*
* @param {String} text
* @return {Sring}
*/
collapseWhiteSpace: function( text ){
return text.replace(/[\t\n\r ]+/g, ' ');
},
/**
* does an object have any of its own properties
*
* @param {Object} obj
* @return {Boolean}
*/
hasProperties: function( obj ) {
var key;
for(key in obj) {
if( obj.hasOwnProperty( key ) ) {
return true;
}
}
return false;
},
/**
* a sort function - to sort objects in an array by a given property
*
* @param {String} property
* @param {Boolean} reverse
* @return {Int}
*/
sortObjects: function(property, reverse) {
reverse = (reverse) ? -1 : 1;
return function (a, b) {
a = a[property];
b = b[property];
if (a < b) {
return reverse * -1;
}
if (a > b) {
return reverse * 1;
}
return 0;
};
}
};
return modules;
} (Modules || {}));

View File

@ -0,0 +1 @@
modules.version = '1.3.3';

View File

@ -0,0 +1,157 @@
from marionette import MarionetteTestCase
from marionette_driver.errors import NoSuchElementException
import threading
import SimpleHTTPServer
import SocketServer
import BaseHTTPServer
import socket
import urllib
import urlparse
import os
DEBUG = True
# Example taken from mozilla-central/browser/components/loop/
# XXX Once we're on a branch with bug 993478 landed, we may want to get
# rid of this HTTP server and just use the built-in one from Marionette,
# since there will less code to maintain, and it will be faster. We'll
# need to consider whether this code wants to be shared with WebDriver tests
# for other browsers, though.
class ThreadingSimpleServer(SocketServer.ThreadingMixIn,
BaseHTTPServer.HTTPServer):
pass
class QuietHttpRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def log_message(self, format, *args, **kwargs):
pass
class BaseTestFrontendUnits(MarionetteTestCase):
@classmethod
def setUpClass(cls):
super(BaseTestFrontendUnits, cls).setUpClass()
if DEBUG:
handler = SimpleHTTPServer.SimpleHTTPRequestHandler
else:
handler = QuietHttpRequestHandler
# Port 0 means to select an arbitrary unused port
cls.server = ThreadingSimpleServer(('', 0), handler)
cls.ip, cls.port = cls.server.server_address
cls.server_thread = threading.Thread(target=cls.server.serve_forever)
cls.server_thread.daemon = False
cls.server_thread.start()
@classmethod
def tearDownClass(cls):
cls.server.shutdown()
cls.server_thread.join()
# make sure everything gets GCed so it doesn't interfere with the next
# test class. Even though this is class-static, each subclass gets
# its own instance of this stuff.
cls.server_thread = None
cls.server = None
def setUp(self):
super(BaseTestFrontendUnits, self).setUp()
# Unfortunately, enforcing preferences currently comes with the side
# effect of launching and restarting the browser before running the
# real functional tests. Bug 1048554 has been filed to track this.
#
# Note: when e10s is enabled by default, this pref can go away. The automatic
# restart will also go away if this is still the only pref set here.
self.marionette.enforce_gecko_prefs({
"browser.tabs.remote.autostart": True
})
# This extends the timeout for find_element. We need this as the tests
# take an amount of time to run after loading, which we have to wait for.
self.marionette.set_search_timeout(120000)
self.marionette.timeouts("page load", 120000)
# srcdir_path should be the directory relative to this file.
def set_server_prefix(self, srcdir_path):
# We may be run from a different path than topsrcdir, e.g. in the case
# of packaged tests. If so, then we have to work out the right directory
# for the local server.
# First find the top of the working directory.
commonPath = os.path.commonprefix([__file__, os.getcwd()])
# Now get the relative path between the two
self.relPath = os.path.relpath(os.path.dirname(__file__), commonPath)
self.relPath = urllib.pathname2url(os.path.join(self.relPath, srcdir_path))
print "http://localhost:" + str(self.port),self.relPath
# Finally join the relative path with the given src path
self.server_prefix = urlparse.urljoin("http://localhost:" + str(self.port),
self.relPath)
def check_page(self, page):
self.marionette.navigate(urlparse.urljoin(self.server_prefix, page))
try:
self.marionette.find_element("id", 'complete')
except NoSuchElementException:
fullPageUrl = urlparse.urljoin(self.relPath, page)
details = "%s: 1 failure encountered\n%s" % \
(fullPageUrl,
self.get_failure_summary(
fullPageUrl, "Waiting for Completion",
"Could not find the test complete indicator"))
raise AssertionError(details)
fail_node = self.marionette.find_element("css selector",
'.failures > em')
if fail_node.text == "0":
return
# This may want to be in a more general place triggerable by an env
# var some day if it ends up being something we need often:
#
# If you have browser-based unit tests which work when loaded manually
# but not from marionette, uncomment the two lines below to break
# on failing tests, so that the browsers won't be torn down, and you
# can use the browser debugging facilities to see what's going on.
#from ipdb import set_trace
#set_trace()
raise AssertionError(self.get_failure_details(page))
def get_failure_summary(self, fullPageUrl, testName, testError):
return "TEST-UNEXPECTED-FAIL | %s | %s - %s" % (fullPageUrl, testName, testError)
def get_failure_details(self, page):
fail_nodes = self.marionette.find_elements("css selector",
'.test.fail')
fullPageUrl = urlparse.urljoin(self.relPath, page)
details = ["%s: %d failure(s) encountered:" % (fullPageUrl, len(fail_nodes))]
for node in fail_nodes:
errorText = node.find_element("css selector", '.error').text
# We have to work our own failure message here, as we could be reporting multiple failures.
# XXX Ideally we'd also give the full test tree for <test name> - that requires walking
# up the DOM tree.
# Format: TEST-UNEXPECTED-FAIL | <filename> | <test name> - <test error>
details.append(
self.get_failure_summary(page,
node.find_element("tag name", 'h2').text.split("\n")[0],
errorText.split("\n")[0]))
details.append(
errorText)
return "\n".join(details)

View File

@ -0,0 +1,18 @@
# Code example copied from mozilla-central/browser/components/loop/
# need to get this dir in the path so that we make the import work
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'marionette'))
from microformats_tester import BaseTestFrontendUnits
class TestInterfaceUnits(BaseTestFrontendUnits):
def setUp(self):
super(TestInterfaceUnits, self).setUp()
self.set_server_prefix("../interface-tests/")
def test_units(self):
self.check_page("index.html")

View File

@ -0,0 +1,19 @@
# Code example copied from mozilla-central/browser/components/loop/
# need to get this dir in the path so that we make the import work
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'marionette'))
from microformats_tester import BaseTestFrontendUnits
class TestModulesUnits(BaseTestFrontendUnits):
def setUp(self):
super(TestModulesUnits, self).setUp()
self.set_server_prefix("../module-tests/")
def test_units(self):
self.check_page("index.html")

View File

@ -0,0 +1,17 @@
# Code example copied from mozilla-central/browser/components/loop/
# need to get this dir in the path so that we make the import work
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'marionette'))
from microformats_tester import BaseTestFrontendUnits
class TestStandardsUnits(BaseTestFrontendUnits):
def setUp(self):
super(TestStandardsUnits, self).setUp()
self.set_server_prefix("../standards-tests/")
def test_units(self):
self.check_page("index.html")

View File

@ -0,0 +1,113 @@
/*
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' );
});
});

View File

@ -0,0 +1,206 @@
/*
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] );
});
});

View File

@ -0,0 +1,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 ), '' );
});
});

View File

@ -0,0 +1,76 @@
<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" />
<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>

View File

@ -0,0 +1,145 @@
/*
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() );
});
});

View File

@ -0,0 +1,56 @@
/*
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' ), '' );
});
});

View File

@ -0,0 +1,25 @@
/*
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/' );
});
});

View File

@ -0,0 +1,93 @@
/*
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"}] );
});
});

View File

@ -0,0 +1,178 @@
<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" />
<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="../standards-tests/mf-mixed-h-card-mixedpropertries.js"></script>
<script src="../standards-tests/mf-mixed-h-card-tworoots.js"></script>
<script src="../standards-tests/mf-mixed-h-entry-mixedroots.js"></script>
<script src="../standards-tests/mf-mixed-h-resume-mixedroots.js"></script>
<script src="../standards-tests/mf-v1-adr-simpleproperties.js"></script>
<script src="../standards-tests/mf-v1-geo-abbrpattern.js"></script>
<script src="../standards-tests/mf-v1-geo-hidden.js"></script>
<script src="../standards-tests/mf-v1-geo-simpleproperties.js"></script>
<script src="../standards-tests/mf-v1-geo-valuetitleclass.js"></script>
<script src="../standards-tests/mf-v1-hcalendar-ampm.js"></script>
<script src="../standards-tests/mf-v1-hcalendar-attendees.js"></script>
<script src="../standards-tests/mf-v1-hcalendar-combining.js"></script>
<script src="../standards-tests/mf-v1-hcalendar-concatenate.js"></script>
<script src="../standards-tests/mf-v1-hcalendar-time.js"></script>
<script src="../standards-tests/mf-v1-hcard-email.js"></script>
<script src="../standards-tests/mf-v1-hcard-format.js"></script>
<script src="../standards-tests/mf-v1-hcard-hyperlinkedphoto.js"></script>
<script src="../standards-tests/mf-v1-hcard-justahyperlink.js"></script>
<script src="../standards-tests/mf-v1-hcard-justaname.js"></script>
<script src="../standards-tests/mf-v1-hcard-multiple.js"></script>
<script src="../standards-tests/mf-v1-hcard-name.js"></script>
<script src="../standards-tests/mf-v1-hcard-single.js"></script>
<script src="../standards-tests/mf-v1-hentry-summarycontent.js"></script>
<script src="../standards-tests/mf-v1-hfeed-simple.js"></script>
<script src="../standards-tests/mf-v1-hnews-all.js"></script>
<script src="../standards-tests/mf-v1-hnews-minimum.js"></script>
<script src="../standards-tests/mf-v1-hproduct-aggregate.js"></script>
<script src="../standards-tests/mf-v1-hproduct-simpleproperties.js"></script>
<script src="../standards-tests/mf-v1-hresume-affiliation.js"></script>
<script src="../standards-tests/mf-v1-hresume-contact.js"></script>
<script src="../standards-tests/mf-v1-hresume-education.js"></script>
<script src="../standards-tests/mf-v1-hresume-skill.js"></script>
<script src="../standards-tests/mf-v1-hresume-work.js"></script>
<script src="../standards-tests/mf-v1-hreview-item.js"></script>
<script src="../standards-tests/mf-v1-hreview-vcard.js"></script>
<script src="../standards-tests/mf-v1-hreview-aggregate-hcard.js"></script>
<script src="../standards-tests/mf-v1-hreview-aggregate-justahyperlink.js"></script>
<script src="../standards-tests/mf-v1-hreview-aggregate-vevent.js"></script>
<script src="../standards-tests/mf-v1-includes-hcarditemref.js"></script>
<script src="../standards-tests/mf-v1-includes-heventitemref.js"></script>
<script src="../standards-tests/mf-v1-includes-hyperlink.js"></script>
<script src="../standards-tests/mf-v1-includes-object.js"></script>
<script src="../standards-tests/mf-v1-includes-table.js"></script>
<script src="../standards-tests/mf-v2-h-adr-geo.js"></script>
<script src="../standards-tests/mf-v2-h-adr-geourl.js"></script>
<script src="../standards-tests/mf-v2-h-adr-justaname.js"></script>
<script src="../standards-tests/mf-v2-h-adr-simpleproperties.js"></script>
<script src="../standards-tests/mf-v2-h-as-note-note.js"></script>
<script src="../standards-tests/mf-v2-h-card-baseurl.js"></script>
<script src="../standards-tests/mf-v2-h-card-childimplied.js"></script>
<script src="../standards-tests/mf-v2-h-card-extendeddescription.js"></script>
<script src="../standards-tests/mf-v2-h-card-hcard.js"></script>
<script src="../standards-tests/mf-v2-h-card-horghcard.js"></script>
<script src="../standards-tests/mf-v2-h-card-hyperlinkedphoto.js"></script>
<script src="../standards-tests/mf-v2-h-card-impliedname.js"></script>
<script src="../standards-tests/mf-v2-h-card-impliedphoto.js"></script>
<script src="../standards-tests/mf-v2-h-card-impliedurl.js"></script>
<script src="../standards-tests/mf-v2-h-card-justahyperlink.js"></script>
<script src="../standards-tests/mf-v2-h-card-justaname.js"></script>
<script src="../standards-tests/mf-v2-h-card-nested.js"></script>
<script src="../standards-tests/mf-v2-h-card-p-property.js"></script>
<script src="../standards-tests/mf-v2-h-card-relativeurls.js"></script>
<script src="../standards-tests/mf-v2-h-entry-impliedvalue-nested.js"></script>
<script src="../standards-tests/mf-v2-h-entry-justahyperlink.js"></script>
<script src="../standards-tests/mf-v2-h-entry-justaname.js"></script>
<script src="../standards-tests/mf-v2-h-entry-summarycontent.js"></script>
<script src="../standards-tests/mf-v2-h-entry-u-property.js"></script>
<script src="../standards-tests/mf-v2-h-entry-urlincontent.js"></script>
<script src="../standards-tests/mf-v2-h-event-ampm.js"></script>
<script src="../standards-tests/mf-v2-h-event-attendees.js"></script>
<script src="../standards-tests/mf-v2-h-event-combining.js"></script>
<script src="../standards-tests/mf-v2-h-event-concatenate.js"></script>
<script src="../standards-tests/mf-v2-h-event-dates.js"></script>
<script src="../standards-tests/mf-v2-h-event-dt-property.js"></script>
<script src="../standards-tests/mf-v2-h-event-justahyperlink.js"></script>
<script src="../standards-tests/mf-v2-h-event-justaname.js"></script>
<script src="../standards-tests/mf-v2-h-event-time.js"></script>
<script src="../standards-tests/mf-v2-h-feed-implied-title.js"></script>
<script src="../standards-tests/mf-v2-h-feed-simple.js"></script>
<script src="../standards-tests/mf-v2-h-geo-abbrpattern.js"></script>
<script src="../standards-tests/mf-v2-h-geo-altitude.js"></script>
<script src="../standards-tests/mf-v2-h-geo-hidden.js"></script>
<script src="../standards-tests/mf-v2-h-geo-justaname.js"></script>
<script src="../standards-tests/mf-v2-h-geo-simpleproperties.js"></script>
<script src="../standards-tests/mf-v2-h-geo-valuetitleclass.js"></script>
<script src="../standards-tests/mf-v2-h-news-all.js"></script>
<script src="../standards-tests/mf-v2-h-news-minimum.js"></script>
<script src="../standards-tests/mf-v2-h-org-hyperlink.js"></script>
<script src="../standards-tests/mf-v2-h-org-simple.js"></script>
<script src="../standards-tests/mf-v2-h-org-simpleproperties.js"></script>
<script src="../standards-tests/mf-v2-h-product-aggregate.js"></script>
<script src="../standards-tests/mf-v2-h-product-justahyperlink.js"></script>
<script src="../standards-tests/mf-v2-h-product-justaname.js"></script>
<script src="../standards-tests/mf-v2-h-product-simpleproperties.js"></script>
<script src="../standards-tests/mf-v2-h-recipe-all.js"></script>
<script src="../standards-tests/mf-v2-h-recipe-minimum.js"></script>
<script src="../standards-tests/mf-v2-h-resume-affiliation.js"></script>
<script src="../standards-tests/mf-v2-h-resume-contact.js"></script>
<script src="../standards-tests/mf-v2-h-resume-education.js"></script>
<script src="../standards-tests/mf-v2-h-resume-justaname.js"></script>
<script src="../standards-tests/mf-v2-h-resume-skill.js"></script>
<script src="../standards-tests/mf-v2-h-resume-work.js"></script>
<script src="../standards-tests/mf-v2-h-review-hyperlink.js"></script>
<script src="../standards-tests/mf-v2-h-review-implieditem.js"></script>
<script src="../standards-tests/mf-v2-h-review-item.js"></script>
<script src="../standards-tests/mf-v2-h-review-justaname.js"></script>
<script src="../standards-tests/mf-v2-h-review-photo.js"></script>
<script src="../standards-tests/mf-v2-h-review-vcard.js"></script>
<script src="../standards-tests/mf-v2-h-review-aggregate-hevent.js"></script>
<script src="../standards-tests/mf-v2-h-review-aggregate-justahyperlink.js"></script>
<script src="../standards-tests/mf-v2-h-review-aggregate-simpleproperties.js"></script>
<script src="../standards-tests/mf-v2-rel-duplicate-rels.js"></script>
<script src="../standards-tests/mf-v2-rel-license.js"></script>
<script src="../standards-tests/mf-v2-rel-nofollow.js"></script>
<script src="../standards-tests/mf-v2-rel-rel-urls.js"></script>
<script src="../standards-tests/mf-v2-rel-varying-text-duplicate-rels.js"></script>
<script src="../standards-tests/mf-v2-rel-xfn-all.js"></script>
<script src="../standards-tests/mf-v2-rel-xfn-elsewhere.js"></script>
</head><body>
<h3 class="capitalize">Microformats-shiv: standards tests</h3>
<p>Standards tests built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST). Downloaded from github repo: microformats/tests version v0.1.24</p>
<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>

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-mixed/h-card/mixedpropertries
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('h-card', function() {
var htmlFragment = "<div class=\"h-card\">\n <p>\n <a class=\"p-name p-org u-url\" href=\"http://mozilla.org/\">Mozilla Foundation</a>\n <img class=\"logo\" src=\"../logo.jpg\"/>\n </p>\n <p class=\"adr\">\n <span class=\"street-address\">665 3rd St.</span> \n <span class=\"extended-address\">Suite 207</span> \n <span class=\"locality\">San Francisco</span>, \n <span class=\"region\">CA</span> \n <span class=\"postal-code\">94107</span> \n <span class=\"p-country-name\">U.S.A.</span> \n </p>\n</div>";
var expected = {"items":[{"type":["h-card"],"properties":{"name":["Mozilla Foundation"],"org":["Mozilla Foundation"],"url":["http://mozilla.org/"],"adr":[{"value":"665 3rd St. \n Suite 207 \n San Francisco, \n CA \n 94107 \n U.S.A.","type":["h-adr"],"properties":{"street-address":["665 3rd St."],"extended-address":["Suite 207"],"locality":["San Francisco"],"region":["CA"],"postal-code":["94107"]}}]}}],"rels":{},"rel-urls":{}};
it('mixedpropertries', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-mixed/h-card/tworoots
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('h-card', function() {
var htmlFragment = "<p class=\"h-card vcard\">Frances Berriman</p>";
var expected = {"items":[{"type":["h-card"],"properties":{"name":["Frances Berriman"]}}],"rels":{},"rel-urls":{}};
it('tworoots', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-mixed/h-entry/mixedroots
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('h-entry', function() {
var htmlFragment = "<!-- simplified version of http://aaronparecki.com/notes/2013/10/18/2/realtimeconf-mapattack -->\n<base href=\"http://aaronparecki.com/\" />\n\n<div class=\"h-entry\">\n <div class=\"h-card vcard author p-author\">\n <img class=\"photo logo u-photo u-logo\" src=\"https://aaronparecki.com/images/aaronpk.png\" alt=\"Aaron Parecki\"/>\n <a href=\"https://aaronparecki.com/\" rel=\"author\" class=\"u-url u-uid url\">aaronparecki.com</a>\n <a class=\"p-name fn value\" href=\"https://aaronparecki.com/\">Aaron Parecki</a>\n <a href=\"https://plus.google.com/117847912875913905493\" rel=\"author\" class=\"google-profile\">Aaron Parecki</a>\n </div>\n <div class=\"entry-content e-content p-name\">Did you play\n <a href=\"http://twitter.com/playmapattack\">@playmapattack</a>at\n <a href=\"/tag/realtimeconf\">#<span class=\"p-category\">realtimeconf</span></a>? Here is some more info about how we built it!\n <a href=\"http://pdx.esri.com/blog/2013/10/17/introducting-mapattack/\"><span class=\"protocol\">http://</span>pdx.esri.com/blog/2013/10/17/introducting-mapattack/</a>\n </div>\n</div>";
var expected = {"items":[{"type":["h-entry"],"properties":{"author":[{"value":"aaronparecki.com\n Aaron Parecki\n Aaron Parecki","type":["h-card"],"properties":{"photo":["https://aaronparecki.com/images/aaronpk.png"],"logo":["https://aaronparecki.com/images/aaronpk.png"],"url":["https://aaronparecki.com/"],"uid":["https://aaronparecki.com/"],"name":["Aaron Parecki"]}}],"content":[{"value":"Did you play\n @playmapattackat\n #realtimeconf? Here is some more info about how we built it!\n http://pdx.esri.com/blog/2013/10/17/introducting-mapattack/","html":"Did you play\n <a href=\"http://twitter.com/playmapattack\">@playmapattack</a>at\n <a href=\"http://aaronparecki.com/tag/realtimeconf\">#<span class=\"p-category\">realtimeconf</span></a>? Here is some more info about how we built it!\n <a href=\"http://pdx.esri.com/blog/2013/10/17/introducting-mapattack/\"><span class=\"protocol\">http://</span>pdx.esri.com/blog/2013/10/17/introducting-mapattack/</a>\n "}],"name":["Did you play\n @playmapattackat\n #realtimeconf? Here is some more info about how we built it!\n http://pdx.esri.com/blog/2013/10/17/introducting-mapattack/"],"category":["realtimeconf"]}}],"rels":{"author":["https://aaronparecki.com/","https://plus.google.com/117847912875913905493"]},"rel-urls":{"https://aaronparecki.com/":{"text":"aaronparecki.com","rels":["author"]},"https://plus.google.com/117847912875913905493":{"text":"Aaron Parecki","rels":["author"]}}};
it('mixedroots', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-mixed/h-resume/mixedroots
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('h-resume', function() {
var htmlFragment = "<meta charset=\"utf-8\">\n<div class=\"h-resume\">\n <div class=\"p-contact vcard\">\n <p class=\"fn\">Tim Berners-Lee</p>\n <p class=\"title\">Director of the World Wide Web Foundation</p>\n </div>\n <p class=\"p-summary\">Invented the World Wide Web.</p><hr />\n <div class=\"p-experience vevent vcard\">\n <p class=\"title\">Director</p>\n <p><a class=\"fn org summary url\" href=\"http://www.webfoundation.org/\">World Wide Web Foundation</a></p>\n <p>\n <time class=\"dtstart\" datetime=\"2009-01-18\">Jan 2009</time> Present\n <time class=\"duration\" datetime=\"P2Y11M\">(2 years 11 month)</time>\n </p>\n </div>\n</div>";
var expected = {"items":[{"type":["h-resume"],"properties":{"contact":[{"value":"Tim Berners-Lee","type":["h-card"],"properties":{"name":["Tim Berners-Lee"],"job-title":["Director of the World Wide Web Foundation"]}}],"summary":["Invented the World Wide Web."],"experience":[{"value":"World Wide Web Foundation","type":["h-event","h-card"],"properties":{"job-title":["Director"],"name":["World Wide Web Foundation"],"org":["World Wide Web Foundation"],"url":["http://www.webfoundation.org/"],"start":["2009-01-18"],"duration":["P2Y11M"]}}],"name":["Tim Berners-Lee\n Director of the World Wide Web Foundation\n \n Invented the World Wide Web.\n \n Director\n World Wide Web Foundation\n \n Jan 2009 Present\n (2 years 11 month)"]}}],"rels":{},"rel-urls":{}};
it('mixedroots', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/adr/simpleproperties
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('adr', function() {
var htmlFragment = "<p class=\"adr\">\n <span class=\"street-address\">665 3rd St.</span> \n <span class=\"extended-address\">Suite 207</span> \n <span class=\"locality\">San Francisco</span>, \n <span class=\"region\">CA</span> \n <span class=\"postal-code\">94107</span> \n <span class=\"country-name\">U.S.A.</span> \n</p>";
var expected = {"items":[{"type":["h-adr"],"properties":{"street-address":["665 3rd St."],"extended-address":["Suite 207"],"locality":["San Francisco"],"region":["CA"],"postal-code":["94107"],"country-name":["U.S.A."]}}],"rels":{},"rel-urls":{}};
it('simpleproperties', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/geo/abbrpattern
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('geo', function() {
var htmlFragment = "<meta charset=\"utf-8\">\n<p class=\"geo\">\n <abbr class=\"latitude\" title=\"37.408183\">N 37° 24.491</abbr>, \n <abbr class=\"longitude\" title=\"-122.13855\">W 122° 08.313</abbr>\n</p>";
var expected = {"items":[{"type":["h-geo"],"properties":{"latitude":["37.408183"],"longitude":["-122.13855"]}}],"rels":{},"rel-urls":{}};
it('abbrpattern', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/geo/hidden
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('geo', function() {
var htmlFragment = "<p>\n <span class=\"geo\">The Bricklayer's Arms\n <span class=\"latitude\">\n <span class=\"value-title\" title=\"51.513458\"> </span> \n </span>\n <span class=\"longitude\">\n <span class=\"value-title\" title=\"-0.14812\"> </span>\n </span>\n </span>\n</p>";
var expected = {"items":[{"type":["h-geo"],"properties":{"latitude":["51.513458"],"longitude":["-0.14812"]}}],"rels":{},"rel-urls":{}};
it('hidden', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/geo/simpleproperties
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('geo', function() {
var htmlFragment = "We are meeting at \n<span class=\"geo\"> \n <span>The Bricklayer's Arms</span>\n (Geo: <span class=\"latitude\">51.513458</span>:\n <span class=\"longitude\">-0.14812</span>)\n</span>";
var expected = {"items":[{"type":["h-geo"],"properties":{"latitude":["51.513458"],"longitude":["-0.14812"]}}],"rels":{},"rel-urls":{}};
it('simpleproperties', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/geo/valuetitleclass
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('geo', function() {
var htmlFragment = "<meta charset=\"utf-8\">\n<p>\n <span class=\"geo\">\n <span class=\"latitude\">\n <span class=\"value-title\" title=\"51.513458\">N 51° 51.345</span>, \n </span>\n <span class=\"longitude\">\n <span class=\"value-title\" title=\"-0.14812\">W -0° 14.812</span>\n </span>\n </span>\n</p>";
var expected = {"items":[{"type":["h-geo"],"properties":{"latitude":["51.513458"],"longitude":["-0.14812"]}}],"rels":{},"rel-urls":{}};
it('valuetitleclass', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hcalendar/ampm
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hcalendar', function() {
var htmlFragment = "<div class=\"vevent\">\n <span class=\"summary\">The 4th Microformat party</span> will be on \n <ul>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <span class=\"value\">07:00:00pm \n </span></li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <span class=\"value\">07:00:00am \n </span></li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <span class=\"value\">07:00pm \n </span></li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <span class=\"value\">07pm \n </span></li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <span class=\"value\">7pm \n </span></li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <span class=\"value\">7:00pm \n </span></li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <span class=\"value\">07:00p.m. \n </span></li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <span class=\"value\">07:00PM \n </span></li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <span class=\"value\">7:00am \n </span></li>\n </ul>\n</div>";
var expected = {"items":[{"type":["h-event"],"properties":{"name":["The 4th Microformat party"],"start":["2009-06-26 19:00:00","2009-06-26 07:00:00","2009-06-26 19:00","2009-06-26 19","2009-06-26 19","2009-06-26 19:00","2009-06-26 19:00","2009-06-26 19:00","2009-06-26 07:00"]}}],"rels":{},"rel-urls":{}};
it('ampm', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hcalendar/attendees
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hcalendar', function() {
var htmlFragment = "<meta charset=\"utf-8\">\n<div class=\"vevent\">\n <span class=\"summary\">CPJ Online Press Freedom Summit</span>\n (<time class=\"dtstart\" datetime=\"2012-10-10\">10 Nov 2012</time>) in\n <span class=\"location\">San Francisco</span>.\n Attendees:\n <ul>\n <li class=\"attendee vcard\"><span class=\"fn\">Brian Warner</span></li>\n <li class=\"attendee vcard\"><span class=\"fn\">Kyle Machulis</span></li>\n <li class=\"attendee vcard\"><span class=\"fn\">Tantek Çelik</span></li>\n <li class=\"attendee vcard\"><span class=\"fn\">Sid Sutter</span></li>\n </ul>\n</div>\n";
var expected = {"items":[{"type":["h-event"],"properties":{"name":["CPJ Online Press Freedom Summit"],"start":["2012-10-10"],"location":["San Francisco"],"attendee":[{"value":"Brian Warner","type":["h-card"],"properties":{"name":["Brian Warner"]}},{"value":"Kyle Machulis","type":["h-card"],"properties":{"name":["Kyle Machulis"]}},{"value":"Tantek Çelik","type":["h-card"],"properties":{"name":["Tantek Çelik"]}},{"value":"Sid Sutter","type":["h-card"],"properties":{"name":["Sid Sutter"]}}]}}],"rels":{},"rel-urls":{}};
it('attendees', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hcalendar/combining
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hcalendar', function() {
var htmlFragment = "<div class=\"vevent\">\n <a class=\"summary url\" href=\"http://indiewebcamp.com/2012\">\n IndieWebCamp 2012\n </a>\n from <time class=\"dtstart\">2012-06-30</time> \n to <time class=\"dtend\">2012-07-01</time> at \n <span class=\"location vcard\">\n <a class=\"fn org url\" href=\"http://geoloqi.com/\">Geoloqi</a>, \n <span class=\"adr\">\n <span class=\"street-address\">920 SW 3rd Ave. Suite 400</span>, \n <span class=\"locality\">Portland</span>, \n <abbr class=\"region\" title=\"Oregon\">OR</abbr>\n </span>\n </span>\n</div>";
var expected = {"items":[{"type":["h-event"],"properties":{"name":["IndieWebCamp 2012"],"url":["http://indiewebcamp.com/2012"],"start":["2012-06-30"],"end":["2012-07-01"],"location":[{"value":"Geoloqi","type":["h-card"],"properties":{"name":["Geoloqi"],"org":["Geoloqi"],"url":["http://geoloqi.com/"],"adr":[{"value":"920 SW 3rd Ave. Suite 400, \n Portland, \n OR","type":["h-adr"],"properties":{"street-address":["920 SW 3rd Ave. Suite 400"],"locality":["Portland"],"region":["Oregon"]}}]}}]}}],"rels":{},"rel-urls":{}};
it('combining', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hcalendar/concatenate
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hcalendar', function() {
var htmlFragment = "<div class=\"vevent\">\n <span class=\"summary\">The 4th Microformat party</span> will be on \n <span class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <time class=\"value\">19:00</time></span> to \n <span class=\"dtend\"><time class=\"value\">22:00</time></span>.\n</div>";
var expected = {"items":[{"type":["h-event"],"properties":{"name":["The 4th Microformat party"],"start":["2009-06-26 19:00"],"end":["2009-06-26 22:00"]}}],"rels":{},"rel-urls":{}};
it('concatenate', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hcalendar/time
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hcalendar', function() {
var htmlFragment = "<div class=\"vevent\">\n <span class=\"summary\">The 4th Microformat party</span> will be on \n <ul>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <time class=\"value\">19:00:00-08:00</time> \n </li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <time class=\"value\">19:00:00-0800</time> \n </li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <time class=\"value\">19:00:00+0800</time> \n </li> \n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <time class=\"value\">19:00:00Z</time> \n </li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <time class=\"value\">19:00:00</time> \n </li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <time class=\"value\">19:00-08:00</time> \n </li> \n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <time class=\"value\">19:00+08:00</time> \n </li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <time class=\"value\">19:00z</time> \n </li>\n <li class=\"dtstart\">\n <time class=\"value\" datetime=\"2009-06-26\">26 July</time>, from\n <time class=\"value\">19:00</time> \n </li> \n <li>\n <time class=\"dtend\" datetime=\"2013-034\">3 February 2013</time>\n </li> \n </ul>\n</div>";
var expected = {"items":[{"type":["h-event"],"properties":{"name":["The 4th Microformat party"],"start":["2009-06-26 19:00:00-08:00","2009-06-26 19:00:00-08:00","2009-06-26 19:00:00+08:00","2009-06-26 19:00:00Z","2009-06-26 19:00:00","2009-06-26 19:00-08:00","2009-06-26 19:00+08:00","2009-06-26 19:00Z","2009-06-26 19:00"],"end":["2013-034"]}}],"rels":{},"rel-urls":{}};
it('time', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hcard/email
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hcard', function() {
var htmlFragment = "<div class=\"vcard\">\n <span class=\"fn\">John Doe</span> \n <ul>\n <li><a class=\"email\" href=\"mailto:john@example.com\">notthis@example.com</a></li>\n <li>\n <span class=\"email\">\n <span class=\"type\">internet</span> \n <a class=\"value\" href=\"mailto:john@example.com\">notthis@example.com</a>\n </span>\n </li> \n <li><a class=\"email\" href=\"mailto:john@example.com?subject=parser-test\">notthis@example.com</a></li>\n <li class=\"email\">john@example.com</li>\n </ul>\n</div>";
var expected = {"items":[{"type":["h-card"],"properties":{"name":["John Doe"],"email":["mailto:john@example.com","mailto:john@example.com","mailto:john@example.com?subject=parser-test","john@example.com"]}}],"rels":{},"rel-urls":{}};
it('email', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hcard/format
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hcard', function() {
var htmlFragment = "<p class=\"vcard\">\n <span class=\"profile-name fn n\">\n <span class=\" given-name \">John</span> \n <span class=\"FAMILY-NAME\">Doe</span> \n </span>\n</p>";
var expected = {"items":[{"type":["h-card"],"properties":{"name":["John \n Doe"],"given-name":["John"]}}],"rels":{},"rel-urls":{}};
it('format', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hcard/hyperlinkedphoto
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hcard', function() {
var htmlFragment = "<a class=\"vcard\" href=\"http://rohit.khare.org/\">\n <img alt=\"Rohit Khare\" src=\"images/photo.gif\" />\n</a>";
var expected = {"items":[{"type":["h-card"],"properties":{}}],"rels":{},"rel-urls":{}};
it('hyperlinkedphoto', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hcard/justahyperlink
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hcard', function() {
var htmlFragment = "<a class=\"vcard\" href=\"http://benward.me/\">Ben Ward</a>";
var expected = {"items":[{"type":["h-card"],"properties":{}}],"rels":{},"rel-urls":{}};
it('justahyperlink', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hcard/justaname
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hcard', function() {
var htmlFragment = "<p class=\"vcard\">Frances Berriman</p>";
var expected = {"items":[{"type":["h-card"],"properties":{}}],"rels":{},"rel-urls":{}};
it('justaname', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hcard/multiple
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hcard', function() {
var htmlFragment = "<base href=\"http://example.com\">\n <div class=\"vcard\">\n \n <div class=\"fn n\"><span class=\"given-name\">John</span> <span class=\"family-name\">Doe</span></div>\n <a class=\"sound\" href=\"http://www.madgex.com/johndoe.mpeg\">Pronunciation of my name</a>\n <div><img class=\"photo\" src=\"images/photo.gif\" alt=\"Photo of John Doe\" /></div>\n\n <p>Nicknames:</p>\n <ul>\n <li class=\"nickname\">Man with no name</li>\n <li class=\"nickname\">Lost boy</li>\n </ul>\n\n <p>About:</p>\n <p class=\"note\">John Doe is one of those names you always have issues with.</p>\n <p class=\"note\">It can be a real problem booking a hotel room with the name John Doe.</p>\n\n <p>Companies:</p>\n <div>\n <img class=\"logo\" src=\"images/logo.gif\" alt=\"Madgex company logo\" />\n <img class=\"logo\" src=\"images/logo.gif\" alt=\"Web Feet Media company logo\" />\n </div>\n <ul>\n <li><a class=\"url org\" href=\"http://www.madgex.com/\">Madgex</a> <span class=\"title\">Creative Director</span></li>\n <li><a class=\"url org\" href=\"http://www.webfeetmedia.com/\">Web Feet Media Ltd</a> <span class=\"title\">Owner</span></li>\n </ul>\n \n <p>Tags: \n <a rel=\"tag\" class=\"category\" href=\"http://en.wikipedia.org/wiki/design\">design</a>, \n <a rel=\"tag\" class=\"category\" href=\"http://en.wikipedia.org/wiki/development\">development</a> and\n <a rel=\"tag\" class=\"category\" href=\"http://en.wikipedia.org/wiki/web\">web</a>\n </p>\n \n <p>Phone numbers:</p>\n <ul>\n <li class=\"tel\">\n <span class=\"type\">Work</span> (<span class=\"type\">pref</span>erred):\n <span class=\"value\">+1 415 555 100</span>\n </li>\n <li class=\"tel\"><span class=\"type\">Home</span>: <span class=\"value\">+1 415 555 200</span></li>\n <li class=\"tel\"><span class=\"type\">Postal</span>: <span class=\"value\">+1 415 555 300</span></li>\n </ul>\n \n <p>Emails:</p>\n <ul>\n <li><a class=\"email\" href=\"mailto:john.doe@madgex.com\">John Doe at Madgex</a></li>\n <li><a class=\"email\" href=\"mailto:john.doe@webfeetmedia.com\">John Doe at Web Feet Media</a></li>\n </ul>\n <p>John Doe uses <span class=\"mailer\">PigeonMail 2.1</span> or <span class=\"mailer\">Outlook 2007</span> for email.</p>\n\n <p>Addresses:</p>\n <ul>\n <li class=\"label\">\n <span class=\"adr\">\n <span class=\"type\">Work</span>: \n <span class=\"street-address\">North Street</span>, \n <span class=\"locality\">Brighton</span>, \n <span class=\"country-name\">United Kingdom</span>\n </span>\n \n </li>\n <li class=\"label\">\n <span class=\"adr\">\n <span class=\"type\">Home</span>: \n <span class=\"street-address\">West Street</span>, \n <span class=\"locality\">Brighton</span>, \n <span class=\"country-name\">United Kingdom</span>\n </span>\n </li>\n </ul>\n \n <p>In emergency contact: <span class=\"agent\">Jane Doe</span> or <span class=\"agent vcard\"><span class=\"fn\">Dave Doe</span></span>.</p>\n <p>Key: <span class=\"key\">hd02$Gfu*d%dh87KTa2=23934532479</span></p>\n</div>";
var expected = {"items":[{"type":["h-card"],"properties":{"name":["John Doe"],"given-name":["John"],"family-name":["Doe"],"sound":["http://www.madgex.com/johndoe.mpeg"],"photo":["http://example.com/images/photo.gif"],"nickname":["Man with no name","Lost boy"],"note":["John Doe is one of those names you always have issues with.","It can be a real problem booking a hotel room with the name John Doe."],"logo":["http://example.com/images/logo.gif","http://example.com/images/logo.gif"],"url":["http://www.madgex.com/","http://www.webfeetmedia.com/"],"org":["Madgex","Web Feet Media Ltd"],"job-title":["Creative Director","Owner"],"category":["design","development","web"],"tel":["+1 415 555 100","+1 415 555 200","+1 415 555 300"],"email":["mailto:john.doe@madgex.com","mailto:john.doe@webfeetmedia.com"],"mailer":["PigeonMail 2.1","Outlook 2007"],"label":["Work: \n North Street, \n Brighton, \n United Kingdom","Home: \n West Street, \n Brighton, \n United Kingdom"],"adr":[{"value":"Work: \n North Street, \n Brighton, \n United Kingdom","type":["h-adr"],"properties":{"street-address":["North Street"],"locality":["Brighton"],"country-name":["United Kingdom"]}},{"value":"Home: \n West Street, \n Brighton, \n United Kingdom","type":["h-adr"],"properties":{"street-address":["West Street"],"locality":["Brighton"],"country-name":["United Kingdom"]}}],"agent":["Jane Doe",{"value":"Dave Doe","type":["h-card"],"properties":{"name":["Dave Doe"]}}],"key":["hd02$Gfu*d%dh87KTa2=23934532479"]}}],"rels":{"tag":["http://en.wikipedia.org/wiki/design","http://en.wikipedia.org/wiki/development","http://en.wikipedia.org/wiki/web"]},"rel-urls":{"http://en.wikipedia.org/wiki/design":{"text":"design","rels":["tag"]},"http://en.wikipedia.org/wiki/development":{"text":"development","rels":["tag"]},"http://en.wikipedia.org/wiki/web":{"text":"web","rels":["tag"]}}};
it('multiple', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hcard/name
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hcard', function() {
var htmlFragment = "<base href=\"http://example.com\">\n<div class=\"vcard\">\n <div class=\"name\">\n <span class=\"honorific-prefix\">Dr</span> \n <span class=\"given-name\">John</span> \n <abbr class=\"additional-name\" title=\"Peter\">P</abbr> \n <span class=\"family-name\">Doe</span> \n <data class=\"honorific-suffix\" value=\"MSc\"></data>\n <img class=\"photo honorific-suffix\" src=\"images/logo.gif\" alt=\"PHD\" />\n </div>\n</div>";
var expected = {"items":[{"type":["h-card"],"properties":{"honorific-prefix":["Dr"],"given-name":["John"],"additional-name":["Peter"],"family-name":["Doe"],"honorific-suffix":["MSc","PHD"],"photo":["http://example.com/images/logo.gif"]}}],"rels":{},"rel-urls":{}};
it('name', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hcard/single
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hcard', function() {
var htmlFragment = "<div class=\"vcard\">\n \n <div class=\"fn n\"><span class=\"given-name sort-string\">John</span> Doe</div>\n <div>Birthday: <abbr class=\"bday\" title=\"2000-01-01T00:00:00-08:00\">January 1st, 2000</abbr></div>\n <div>Role: <span class=\"role\">Designer</span></div>\n <div>Location: <abbr class=\"geo\" title=\"30.267991;-97.739568\">Brighton</abbr></div>\n <div>Time zone: <abbr class=\"tz\" title=\"-05:00\">Eastern Standard Time</abbr></div>\n \n <div>Profile details:\n <div>Profile id: <span class=\"uid\">http://example.com/profiles/johndoe</span></div>\n <div>Details are: <span class=\"class\">Public</span></div>\n <div>Last updated: <abbr class=\"rev\" title=\"2008-01-01T13:45:00\">January 1st, 2008 - 13:45</abbr></div>\n </div>\n </div>";
var expected = {"items":[{"type":["h-card"],"properties":{"name":["John Doe"],"given-name":["John"],"sort-string":["John"],"bday":["2000-01-01 00:00:00-08:00"],"role":["Designer"],"geo":[{"value":"30.267991;-97.739568","type":["h-geo"],"properties":{"name":["30.267991;-97.739568"]}}],"tz":["-05:00"],"uid":["http://example.com/profiles/johndoe"],"class":["Public"],"rev":["2008-01-01 13:45:00"]}}],"rels":{},"rel-urls":{}};
it('single', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hentry/summarycontent
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hentry', function() {
var htmlFragment = "<meta charset=\"utf-8\">\n<div class=\"hentry\">\n <h1><a class=\"entry-title\" href=\"http://microformats.org/2012/06/25/microformats-org-at-7\">microformats.org at 7</a></h1>\n <div class=\"entry-content\">\n <p class=\"entry-summary\">Last week the microformats.org community \n celebrated its 7th birthday at a gathering hosted by Mozilla in \n San Francisco and recognized accomplishments, challenges, and \n opportunities.</p>\n\n <p>The microformats tagline “humans first, machines second” \n forms the basis of many of our \n <a href=\"http://microformats.org/wiki/principles\">principles</a>, and \n in that regard, wed like to recognize a few people and \n thank them for their years of volunteer service </p>\n </div> \n <p>Updated \n <time class=\"updated\" datetime=\"2012-06-25T17:08:26\">June 25th, 2012</time> by\n <span class=\"author vcard\"><a class=\"fn url\" href=\"http://tantek.com/\">Tantek</a></span>\n </p>\n</div>";
var expected = {"items":[{"type":["h-entry"],"properties":{"name":["microformats.org at 7"],"content":[{"value":"Last week the microformats.org community \n celebrated its 7th birthday at a gathering hosted by Mozilla in \n San Francisco and recognized accomplishments, challenges, and \n opportunities.\n\n The microformats tagline “humans first, machines second” \n forms the basis of many of our \n principles, and \n in that regard, wed like to recognize a few people and \n thank them for their years of volunteer service","html":"\n <p class=\"entry-summary\">Last week the microformats.org community \n celebrated its 7th birthday at a gathering hosted by Mozilla in \n San Francisco and recognized accomplishments, challenges, and \n opportunities.</p>\n\n <p>The microformats tagline “humans first, machines second” \n forms the basis of many of our \n <a href=\"http://microformats.org/wiki/principles\">principles</a>, and \n in that regard, wed like to recognize a few people and \n thank them for their years of volunteer service </p>\n "}],"summary":["Last week the microformats.org community \n celebrated its 7th birthday at a gathering hosted by Mozilla in \n San Francisco and recognized accomplishments, challenges, and \n opportunities."],"updated":["2012-06-25 17:08:26"],"author":[{"value":"Tantek","type":["h-card"],"properties":{"name":["Tantek"],"url":["http://tantek.com/"]}}]}}],"rels":{},"rel-urls":{}};
it('summarycontent', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hfeed/simple
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hfeed', function() {
var htmlFragment = "<section class=\"hfeed\">\n\t<h1 class=\"name\">Microformats blog</h1>\n\t<span class=\"author vcard\"><a class=\"fn url\" href=\"http://tantek.com/\">Tantek</a></span>\n\t<a class=\"url\" href=\"http://microformats.org/blog\">permlink</a>\n\t<img class=\"photo\" src=\"photo.jpeg\"/>\n\t<p>\n\t\tTags: <a rel=\"tag\" href=\"tags/microformats\">microformats</a>, \n\t\t<a rel=\"tag\" href=\"tags/html\">html</a>\n\t</p>\n\t\n\t<div class=\"hentry\">\n\t <h1><a class=\"entry-title\" rel=\"bookmark\" href=\"http://microformats.org/2012/06/25/microformats-org-at-7\">microformats.org at 7</a></h1>\n\t <div class=\"entry-content\">\n\t <p class=\"entry-summary\">Last week the microformats.org community \n\t celebrated its 7th birthday at a gathering hosted by Mozilla in \n\t San Francisco and recognized accomplishments, challenges, and \n\t opportunities.</p>\n\t\n\t <p>The microformats tagline “humans first, machines second” \n\t forms the basis of many of our \n\t <a href=\"http://microformats.org/wiki/principles\">principles</a>, and \n\t in that regard, wed like to recognize a few people and \n\t thank them for their years of volunteer service </p>\n\t </div> \n\t <p>Updated \n\t <time class=\"updated\" datetime=\"2012-06-25T17:08:26\">June 25th, 2012</time>\n\t </p>\n\t</div>\n\t\n</section>";
var expected = {"items":[{"type":["h-feed"],"properties":{"author":[{"value":"Tantek","type":["h-card"],"properties":{"name":["Tantek"],"url":["http://tantek.com/"]}}],"url":["http://microformats.org/blog"],"photo":["http://example.com/photo.jpeg"],"category":["microformats","html"]},"children":[{"value":"microformats.org at 7\n\t \n\t Last week the microformats.org community \n\t celebrated its 7th birthday at a gathering hosted by Mozilla in \n\t San Francisco and recognized accomplishments, challenges, and \n\t opportunities.\n\t\n\t The microformats tagline “humans first, machines second” \n\t forms the basis of many of our \n\t principles, and \n\t in that regard, wed like to recognize a few people and \n\t thank them for their years of volunteer service \n\t \n\t Updated \n\t June 25th, 2012","type":["h-entry"],"properties":{"name":["microformats.org at 7"],"url":["http://microformats.org/2012/06/25/microformats-org-at-7"],"content":[{"value":"Last week the microformats.org community \n\t celebrated its 7th birthday at a gathering hosted by Mozilla in \n\t San Francisco and recognized accomplishments, challenges, and \n\t opportunities.\n\t\n\t The microformats tagline “humans first, machines second” \n\t forms the basis of many of our \n\t principles, and \n\t in that regard, wed like to recognize a few people and \n\t thank them for their years of volunteer service","html":"\n\t <p class=\"entry-summary\">Last week the microformats.org community \n\t celebrated its 7th birthday at a gathering hosted by Mozilla in \n\t San Francisco and recognized accomplishments, challenges, and \n\t opportunities.</p>\n\t\n\t <p>The microformats tagline “humans first, machines second” \n\t forms the basis of many of our \n\t <a href=\"http://microformats.org/wiki/principles\">principles</a>, and \n\t in that regard, wed like to recognize a few people and \n\t thank them for their years of volunteer service </p>\n\t "}],"summary":["Last week the microformats.org community \n\t celebrated its 7th birthday at a gathering hosted by Mozilla in \n\t San Francisco and recognized accomplishments, challenges, and \n\t opportunities."],"updated":["2012-06-25 17:08:26"]}}]}],"rels":{"tag":["http://example.com/tags/microformats","http://example.com/tags/html"],"bookmark":["http://microformats.org/2012/06/25/microformats-org-at-7"]},"rel-urls":{"http://example.com/tags/microformats":{"text":"microformats","rels":["tag"]},"http://example.com/tags/html":{"text":"html","rels":["tag"]},"http://microformats.org/2012/06/25/microformats-org-at-7":{"text":"microformats.org at 7","rels":["bookmark"]}}};
it('simple', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hnews/all
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hnews', function() {
var htmlFragment = "<div class=\"hnews\">\n <div class=\"entry hentry\">\n <h1><a class=\"entry-title\" rel=\"bookmark\" href=\"http://microformats.org/2012/06/25/microformats-org-at-7\">microformats.org at 7</a></h1>\n <div class=\"entry-content\">\n <p class=\"entry-summary\">Last week the microformats.org community \n celebrated its 7th birthday at a gathering hosted by Mozilla in \n San Francisco and recognized accomplishments, challenges, and \n opportunities.</p>\n\n <p>The microformats tagline “humans first, machines second” \n forms the basis of many of our \n <a href=\"http://microformats.org/wiki/principles\">principles</a>, and \n in that regard, wed like to recognize a few people and \n thank them for their years of volunteer service </p>\n </div> \n <p>Updated \n <time class=\"updated\" datetime=\"2012-06-25T17:08:26\">June 25th, 2012</time> by\n <span class=\"author vcard\"><a class=\"fn url\" href=\"http://tantek.com/\">Tantek</a></span>\n </p>\n </div>\n\n <p>\n <span class=\"dateline vcard\">\n <span class=\"adr\">\n <span class=\"locality\">San Francisco</span>, \n <span class=\"region\">CA</span> \n </span>\n </span>\n (Geo: <span class=\"geo\">37.774921;-122.445202</span>) \n <span class=\"source-org vcard\">\n <a class=\"fn org url\" href=\"http://microformats.org/\">microformats.org</a>\n </span>\n </p>\n <p>\n <a rel=\"principles\" href=\"http://microformats.org/wiki/Category:public_domain_license\">Publishing policy</a>\n </p>\n</div>";
var expected = {"items":[{"type":["h-news"],"properties":{"entry":[{"value":"microformats.org at 7","type":["h-entry"],"properties":{"name":["microformats.org at 7"],"url":["http://microformats.org/2012/06/25/microformats-org-at-7"],"content":[{"value":"Last week the microformats.org community \n celebrated its 7th birthday at a gathering hosted by Mozilla in \n San Francisco and recognized accomplishments, challenges, and \n opportunities.\n\n The microformats tagline “humans first, machines second” \n forms the basis of many of our \n principles, and \n in that regard, wed like to recognize a few people and \n thank them for their years of volunteer service","html":"\n <p class=\"entry-summary\">Last week the microformats.org community \n celebrated its 7th birthday at a gathering hosted by Mozilla in \n San Francisco and recognized accomplishments, challenges, and \n opportunities.</p>\n\n <p>The microformats tagline “humans first, machines second” \n forms the basis of many of our \n <a href=\"http://microformats.org/wiki/principles\">principles</a>, and \n in that regard, wed like to recognize a few people and \n thank them for their years of volunteer service </p>\n "}],"summary":["Last week the microformats.org community \n celebrated its 7th birthday at a gathering hosted by Mozilla in \n San Francisco and recognized accomplishments, challenges, and \n opportunities."],"updated":["2012-06-25 17:08:26"],"author":[{"value":"Tantek","type":["h-card"],"properties":{"name":["Tantek"],"url":["http://tantek.com/"]}}]}}],"dateline":[{"value":"San Francisco, \n CA","type":["h-card"],"properties":{"adr":[{"value":"San Francisco, \n CA","type":["h-adr"],"properties":{"locality":["San Francisco"],"region":["CA"]}}]}}],"geo":[{"value":"37.774921;-122.445202","type":["h-geo"],"properties":{"name":["37.774921;-122.445202"]}}],"source-org":[{"value":"microformats.org","type":["h-card"],"properties":{"name":["microformats.org"],"org":["microformats.org"],"url":["http://microformats.org/"]}}],"principles":["http://microformats.org/wiki/Category:public_domain_license"]}}],"rels":{"bookmark":["http://microformats.org/2012/06/25/microformats-org-at-7"],"principles":["http://microformats.org/wiki/Category:public_domain_license"]},"rel-urls":{"http://microformats.org/2012/06/25/microformats-org-at-7":{"text":"microformats.org at 7","rels":["bookmark"]},"http://microformats.org/wiki/Category:public_domain_license":{"text":"Publishing policy","rels":["principles"]}}};
it('all', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hnews/minimum
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hnews', function() {
var htmlFragment = "<div class=\"hnews\">\n <div class=\"entry hentry\">\n <h1><a class=\"entry-title\" rel=\"bookmark\" href=\"http://microformats.org/2012/06/25/microformats-org-at-7\">microformats.org at 7</a></h1>\n <div class=\"entry-content\">\n <p class=\"entry-summary\">Last week the microformats.org community \n celebrated its 7th birthday at a gathering hosted by Mozilla in \n San Francisco and recognized accomplishments, challenges, and \n opportunities.</p>\n\n <p>The microformats tagline “humans first, machines second” \n forms the basis of many of our \n <a href=\"http://microformats.org/wiki/principles\">principles</a>, and \n in that regard, wed like to recognize a few people and \n thank them for their years of volunteer service </p>\n </div> \n <p>Updated \n <time class=\"updated\" datetime=\"2012-06-25T17:08:26\">June 25th, 2012</time> by\n <span class=\"author vcard\"><a class=\"fn url\" href=\"http://tantek.com/\">Tantek</a></span>\n </p>\n </div>\n\n <p class=\"source-org vcard\">\n <a class=\"fn org url\" href=\"http://microformats.org/\">microformats.org</a> \n </p>\n</div>";
var expected = {"items":[{"type":["h-news"],"properties":{"entry":[{"value":"microformats.org at 7","type":["h-entry"],"properties":{"name":["microformats.org at 7"],"url":["http://microformats.org/2012/06/25/microformats-org-at-7"],"content":[{"value":"Last week the microformats.org community \n celebrated its 7th birthday at a gathering hosted by Mozilla in \n San Francisco and recognized accomplishments, challenges, and \n opportunities.\n\n The microformats tagline “humans first, machines second” \n forms the basis of many of our \n principles, and \n in that regard, wed like to recognize a few people and \n thank them for their years of volunteer service","html":"\n <p class=\"entry-summary\">Last week the microformats.org community \n celebrated its 7th birthday at a gathering hosted by Mozilla in \n San Francisco and recognized accomplishments, challenges, and \n opportunities.</p>\n\n <p>The microformats tagline “humans first, machines second” \n forms the basis of many of our \n <a href=\"http://microformats.org/wiki/principles\">principles</a>, and \n in that regard, wed like to recognize a few people and \n thank them for their years of volunteer service </p>\n "}],"summary":["Last week the microformats.org community \n celebrated its 7th birthday at a gathering hosted by Mozilla in \n San Francisco and recognized accomplishments, challenges, and \n opportunities."],"updated":["2012-06-25 17:08:26"],"author":[{"value":"Tantek","type":["h-card"],"properties":{"name":["Tantek"],"url":["http://tantek.com/"]}}]}}],"source-org":[{"value":"microformats.org","type":["h-card"],"properties":{"name":["microformats.org"],"org":["microformats.org"],"url":["http://microformats.org/"]}}]}}],"rels":{"bookmark":["http://microformats.org/2012/06/25/microformats-org-at-7"]},"rel-urls":{"http://microformats.org/2012/06/25/microformats-org-at-7":{"text":"microformats.org at 7","rels":["bookmark"]}}};
it('minimum', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hproduct/aggregate
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hproduct', function() {
var htmlFragment = "<meta charset=\"utf-8\">\n<div class=\"hproduct\">\n <h2 class=\"fn\">Raspberry Pi</h2>\n <img class=\"photo\" src=\"http://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/RaspberryPi.jpg/320px-RaspberryPi.jpg\" />\n <p class=\"description\">The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. Its a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn programming.</p>\n <a class=\"url\" href=\"http://www.raspberrypi.org/\">More info about the Raspberry Pi</a>\n <p class=\"price\">£29.95</p>\n <p class=\"review hreview-aggregate\">\n <span class=\"rating\">\n <span class=\"average value\">9.2</span> out of \n <span class=\"best\">10</span> \n based on <span class=\"count\">178</span> reviews\n </span>\n </p>\n <p>Categories: \n <a rel=\"tag\" href=\"http://en.wikipedia.org/wiki/computer\" class=\"category\">Computer</a>, \n <a rel=\"tag\" href=\"http://en.wikipedia.org/wiki/education\" class=\"category\">Education</a>\n </p>\n <p class=\"brand vcard\">From: \n <span class=\"fn org\">The Raspberry Pi Foundation</span> - \n <span class=\"adr\">\n <span class=\"locality\">Cambridge</span> \n <span class=\"country-name\">UK</span>\n </span>\n </p>\n</div>";
var expected = {"items":[{"type":["h-product"],"properties":{"name":["Raspberry Pi"],"photo":["http://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/RaspberryPi.jpg/320px-RaspberryPi.jpg"],"description":[{"value":"The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. Its a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn programming.","html":"The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. Its a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn programming."}],"url":["http://www.raspberrypi.org/"],"price":["£29.95"],"review":[{"value":"9.2 out of \n 10 \n based on 178 reviews","type":["h-review-aggregate"],"properties":{"rating":["9.2"],"average":["9.2"],"best":["10"],"count":["178"]}}],"category":["Computer","Education"],"brand":[{"value":"The Raspberry Pi Foundation","type":["h-card"],"properties":{"name":["The Raspberry Pi Foundation"],"org":["The Raspberry Pi Foundation"],"adr":[{"value":"Cambridge \n UK","type":["h-adr"],"properties":{"locality":["Cambridge"],"country-name":["UK"]}}]}}]}}],"rels":{"tag":["http://en.wikipedia.org/wiki/computer","http://en.wikipedia.org/wiki/education"]},"rel-urls":{"http://en.wikipedia.org/wiki/computer":{"text":"Computer","rels":["tag"]},"http://en.wikipedia.org/wiki/education":{"text":"Education","rels":["tag"]}}};
it('aggregate', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hproduct/simpleproperties
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hproduct', function() {
var htmlFragment = "<meta charset=\"utf-8\">\n<div class=\"hproduct\">\n <h2 class=\"fn\">Raspberry Pi</h2>\n <img class=\"photo\" src=\"http://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/RaspberryPi.jpg/320px-RaspberryPi.jpg\" />\n <p class=\"description\">The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. Its a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn programming.</p>\n <a class=\"url\" href=\"http://www.raspberrypi.org/\">More info about the Raspberry Pi</a>\n <p class=\"price\">£29.95</p>\n <p class=\"review hreview\"><span class=\"rating\">4.5</span> out of 5</p>\n <p>Categories: \n <a rel=\"tag\" href=\"http://en.wikipedia.org/wiki/computer\" class=\"category\">Computer</a>, \n <a rel=\"tag\" href=\"http://en.wikipedia.org/wiki/education\" class=\"category\">Education</a>\n </p>\n</div>";
var expected = {"items":[{"type":["h-product"],"properties":{"name":["Raspberry Pi"],"photo":["http://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/RaspberryPi.jpg/320px-RaspberryPi.jpg"],"description":[{"value":"The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. Its a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn programming.","html":"The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. Its a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn programming."}],"url":["http://www.raspberrypi.org/"],"price":["£29.95"],"category":["Computer","Education"],"review":[{"value":"4.5 out of 5","type":["h-review"],"properties":{"rating":["4.5"]}}]}}],"rels":{"tag":["http://en.wikipedia.org/wiki/computer","http://en.wikipedia.org/wiki/education"]},"rel-urls":{"http://en.wikipedia.org/wiki/computer":{"text":"Computer","rels":["tag"]},"http://en.wikipedia.org/wiki/education":{"text":"Education","rels":["tag"]}}};
it('simpleproperties', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hresume/affiliation
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hresume', function() {
var htmlFragment = "<div class=\"hresume\">\n <p>\n <span class=\"contact vcard\"><span class=\"fn\">Tim Berners-Lee</span></span>, \n <span class=\"summary\">invented the World Wide Web</span>.\n </p>\n Belongs to following groups:\n <p> \n <a class=\"affiliation vcard\" href=\"http://www.w3.org/\">\n <img class=\"fn photo\" alt=\"W3C\" src=\"http://www.w3.org/Icons/WWW/w3c_home_nb.png\" />\n </a>\n </p> \n</div>";
var expected = {"items":[{"type":["h-resume"],"properties":{"contact":[{"value":"Tim Berners-Lee","type":["h-card"],"properties":{"name":["Tim Berners-Lee"]}}],"summary":["invented the World Wide Web"],"affiliation":[{"type":["h-card"],"properties":{"name":["W3C"],"photo":["http://www.w3.org/Icons/WWW/w3c_home_nb.png"]}}]}}],"rels":{},"rel-urls":{}};
it('affiliation', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hresume/contact
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hresume', function() {
var htmlFragment = "<div class=\"hresume\">\n <div class=\"contact vcard\">\n <p class=\"fn\">Tim Berners-Lee</p>\n <p class=\"org\">MIT</p>\n <p class=\"adr\">\n <span class=\"street-address\">32 Vassar Street</span>, \n <span class=\"extended-address\">Room 32-G524</span>, \n <span class=\"locality\">Cambridge</span>, \n <span class=\"region\">MA</span> \n <span class=\"postal-code\">02139</span>, \n <span class=\"country-name\">USA</span>. \n (<span class=\"type\">Work</span>)\n </p>\n <p>Tel:<span class=\"tel\">+1 (617) 253 5702</span></p>\n <p>Email:<a class=\"email\" href=\"mailto:timbl@w3.org\">timbl@w3.org</a></p>\n </div>\n <p class=\"summary\">Invented the World Wide Web.</p>\n</div>";
var expected = {"items":[{"type":["h-resume"],"properties":{"contact":[{"value":"Tim Berners-Lee","type":["h-card"],"properties":{"name":["Tim Berners-Lee"],"org":["MIT"],"adr":[{"value":"32 Vassar Street, \n Room 32-G524, \n Cambridge, \n MA \n 02139, \n USA. \n (Work)","type":["h-adr"],"properties":{"street-address":["32 Vassar Street"],"extended-address":["Room 32-G524"],"locality":["Cambridge"],"region":["MA"],"postal-code":["02139"],"country-name":["USA"]}}],"tel":["+1 (617) 253 5702"],"email":["mailto:timbl@w3.org"]}}],"summary":["Invented the World Wide Web."]}}],"rels":{},"rel-urls":{}};
it('contact', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hresume/education
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hresume', function() {
var htmlFragment = "<div class=\"hresume\">\n <div class=\"contact vcard\">\n <p class=\"fn\">Tim Berners-Lee</p>\n <p class=\"title\">Director of the World Wide Web Foundation</p>\n </div>\n <p class=\"summary\">Invented the World Wide Web.</p><hr />\n <p class=\"education vevent vcard\">\n <span class=\"fn summary org\">The Queen's College, Oxford University</span>, \n <span class=\"description\">BA Hons (I) Physics</span> \n <time class=\"dtstart\" datetime=\"1973-09\">1973</time> \n <time class=\"dtend\" datetime=\"1976-06\">1976</time>\n </p>\n</div>";
var expected = {"items":[{"type":["h-resume"],"properties":{"contact":[{"value":"Tim Berners-Lee","type":["h-card"],"properties":{"name":["Tim Berners-Lee"],"job-title":["Director of the World Wide Web Foundation"]}}],"summary":["Invented the World Wide Web."],"education":[{"value":"The Queen's College, Oxford University","type":["h-event","h-card"],"properties":{"name":["The Queen's College, Oxford University"],"org":["The Queen's College, Oxford University"],"description":["BA Hons (I) Physics"],"start":["1973-09"],"end":["1976-06"]}}]}}],"rels":{},"rel-urls":{}};
it('education', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hresume/skill
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hresume', function() {
var htmlFragment = "<div class=\"hresume\"> \n <p>\n <span class=\"contact vcard\"><span class=\"fn\">Tim Berners-Lee</span></span>, \n <span class=\"summary\">invented the World Wide Web</span>.\n </p>\n Skills: \n <ul>\n <li><a class=\"skill\" rel=\"tag\" href=\"http://example.com/skills/informationsystems\">information systems</a></li>\n <li><a class=\"skill\" rel=\"tag\" href=\"http://example.com/skills/advocacy\">advocacy</a></li>\n <li><a class=\"skill\" rel=\"tag\" href=\"http://example.com/skills/leadership\">leadership</a></li>\n </ul>\n</div>";
var expected = {"items":[{"type":["h-resume"],"properties":{"contact":[{"value":"Tim Berners-Lee","type":["h-card"],"properties":{"name":["Tim Berners-Lee"]}}],"summary":["invented the World Wide Web"],"skill":["information systems","advocacy","leadership"]}}],"rels":{"tag":["http://example.com/skills/informationsystems","http://example.com/skills/advocacy","http://example.com/skills/leadership"]},"rel-urls":{"http://example.com/skills/informationsystems":{"text":"information systems","rels":["tag"]},"http://example.com/skills/advocacy":{"text":"advocacy","rels":["tag"]},"http://example.com/skills/leadership":{"text":"leadership","rels":["tag"]}}};
it('skill', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hresume/work
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hresume', function() {
var htmlFragment = "<meta charset=\"utf-8\">\n<div class=\"hresume\">\n <div class=\"contact vcard\">\n <p class=\"fn\">Tim Berners-Lee</p>\n <p class=\"title\">Director of the World Wide Web Foundation</p>\n </div>\n <p class=\"summary\">Invented the World Wide Web.</p><hr />\n <div class=\"experience vevent vcard\">\n <p class=\"title\">Director</p>\n <p><a class=\"fn summary org url\" href=\"http://www.webfoundation.org/\">World Wide Web Foundation</a></p>\n <p>\n <time class=\"dtstart\" datetime=\"2009-01-18\">Jan 2009</time> Present\n <time class=\"duration\" datetime=\"P2Y11M\">(2 years 11 month)</time>\n </p>\n </div>\n</div>";
var expected = {"items":[{"type":["h-resume"],"properties":{"contact":[{"value":"Tim Berners-Lee","type":["h-card"],"properties":{"name":["Tim Berners-Lee"],"job-title":["Director of the World Wide Web Foundation"]}}],"summary":["Invented the World Wide Web."],"experience":[{"value":"World Wide Web Foundation","type":["h-event","h-card"],"properties":{"job-title":["Director"],"name":["World Wide Web Foundation"],"org":["World Wide Web Foundation"],"url":["http://www.webfoundation.org/"],"start":["2009-01-18"],"duration":["P2Y11M"]}}]}}],"rels":{},"rel-urls":{}};
it('work', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hreview-aggregate/hcard
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hreview-aggregate', function() {
var htmlFragment = "<div class=\"hreview-aggregate\">\n <div class=\"item vcard\">\n <h3 class=\"fn org\">Mediterranean Wraps</h3> \n <p>\n <span class=\"adr\">\n <span class=\"street-address\">433 S California Ave</span>, \n <span class=\"locality\">Palo Alto</span>, \n <span class=\"region\">CA</span></span> - \n \n <span class=\"tel\">(650) 321-8189</span>\n </p>\n </div> \n <p class=\"rating\">\n <span class=\"average value\">9.2</span> out of \n <span class=\"best\">10</span> \n based on <span class=\"count\">17</span> reviews\n </p>\n</div>";
var expected = {"items":[{"type":["h-review-aggregate"],"properties":{"item":[{"value":"Mediterranean Wraps","type":["h-item","h-card"],"properties":{"name":["Mediterranean Wraps"],"org":["Mediterranean Wraps"],"adr":[{"value":"433 S California Ave, \n Palo Alto, \n CA","type":["h-adr"],"properties":{"street-address":["433 S California Ave"],"locality":["Palo Alto"],"region":["CA"]}}],"tel":["(650) 321-8189"]}}],"rating":["9.2"],"average":["9.2"],"best":["10"],"count":["17"]}}],"rels":{},"rel-urls":{}};
it('hcard', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hreview-aggregate/justahyperlink
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hreview-aggregate', function() {
var htmlFragment = "<p class=\"hreview-aggregate\">\n <span class=\"item\">\n <a class=\"fn url\" href=\"http://example.com/mediterraneanwraps\">Mediterranean Wraps</a>\n </span> - Rated: \n <span class=\"rating\">4.5</span> out of 5 (<span class=\"count\">6</span> reviews)\n</p>";
var expected = {"items":[{"type":["h-review-aggregate"],"properties":{"item":[{"value":"Mediterranean Wraps","type":["h-item"],"properties":{"name":["Mediterranean Wraps"],"url":["http://example.com/mediterraneanwraps"]}}],"rating":["4.5"],"count":["6"]}}],"rels":{},"rel-urls":{}};
it('justahyperlink', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hreview-aggregate/vevent
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hreview-aggregate', function() {
var htmlFragment = "<div class=\"hreview-aggregate\">\n <div class=\"item vevent\">\n <h3 class=\"summary\">Fullfrontal</h3>\n <p class=\"description\">A one day JavaScript Conference held in Brighton</p>\n <p><time class=\"dtstart\" datetime=\"2012-11-09\">9th November 2012</time></p> \n </div> \n \n <p class=\"rating\">\n <span class=\"average value\">9.9</span> out of \n <span class=\"best\">10</span> \n based on <span class=\"count\">62</span> reviews\n </p>\n</div>";
var expected = {"items":[{"type":["h-review-aggregate"],"properties":{"item":[{"value":"Fullfrontal","type":["h-item","h-event"],"properties":{"name":["Fullfrontal"],"description":["A one day JavaScript Conference held in Brighton"],"start":["2012-11-09"]}}],"rating":["9.9"],"average":["9.9"],"best":["10"],"count":["62"]}}],"rels":{},"rel-urls":{}};
it('vevent', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hreview/item
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hreview', function() {
var htmlFragment = "<base href=\"http://example.com\">\n<div class=\"hreview\">\n <p class=\"item\">\n <img class=\"photo\" src=\"images/photo.gif\" />\n <a class=\"fn url\" href=\"http://example.com/crepeoncole\">Crepes on Cole</a>\n </p>\n <p><span class=\"rating\">5</span> out of 5 stars</p>\n</div>";
var expected = {"items":[{"type":["h-review"],"properties":{"item":[{"value":"Crepes on Cole","type":["h-item"],"properties":{"photo":["http://example.com/images/photo.gif"],"name":["Crepes on Cole"],"url":["http://example.com/crepeoncole"]}}],"rating":["5"]}}],"rels":{},"rel-urls":{}};
it('item', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/hreview/vcard
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('hreview', function() {
var htmlFragment = "<div class=\"hreview\">\n <span><span class=\"rating\">5</span> out of 5 stars</span>\n <h4 class=\"summary\">Crepes on Cole is awesome</h4>\n <span class=\"reviewer vcard\">\n Reviewer: <span class=\"fn\">Tantek</span> - \n </span>\n <time class=\"reviewed\" datetime=\"2005-04-18\">April 18, 2005</time>\n <div class=\"description\">\n <p class=\"item vcard\">\n <span class=\"fn org\">Crepes on Cole</span> is one of the best little \n creperies in <span class=\"adr\"><span class=\"locality\">San Francisco</span></span>.\n Excellent food and service. Plenty of tables in a variety of sizes \n for parties large and small. Window seating makes for excellent \n people watching to/from the N-Judah which stops right outside. \n I've had many fun social gatherings here, as well as gotten \n plenty of work done thanks to neighborhood WiFi.\n </p>\n </div>\n <p>Visit date: <span>April 2005</span></p>\n <p>Food eaten: <a rel=\"tag\" href=\"http://en.wikipedia.org/wiki/crepe\">crepe</a></p>\n <p>Permanent link for review: <a rel=\"self bookmark\" href=\"http://example.com/crepe\">http://example.com/crepe</a></p>\n <p><a rel=\"license\" href=\"http://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License\">Creative Commons Attribution-ShareAlike License</a></p>\n</div>";
var expected = {"items":[{"type":["h-review"],"properties":{"rating":["5"],"name":["Crepes on Cole is awesome"],"reviewer":[{"value":"Tantek","type":["h-card"],"properties":{"name":["Tantek"]}}],"description":[{"value":"Crepes on Cole is one of the best little \n creperies in San Francisco.\n Excellent food and service. Plenty of tables in a variety of sizes \n for parties large and small. Window seating makes for excellent \n people watching to/from the N-Judah which stops right outside. \n I've had many fun social gatherings here, as well as gotten \n plenty of work done thanks to neighborhood WiFi.","html":"\n <p class=\"item vcard\">\n <span class=\"fn org\">Crepes on Cole</span> is one of the best little \n creperies in <span class=\"adr\"><span class=\"locality\">San Francisco</span></span>.\n Excellent food and service. Plenty of tables in a variety of sizes \n for parties large and small. Window seating makes for excellent \n people watching to/from the N-Judah which stops right outside. \n I've had many fun social gatherings here, as well as gotten \n plenty of work done thanks to neighborhood WiFi.\n </p>\n "}],"item":[{"value":"Crepes on Cole","type":["h-item","h-card"],"properties":{"name":["Crepes on Cole"],"org":["Crepes on Cole"],"adr":[{"value":"San Francisco","type":["h-adr"],"properties":{"locality":["San Francisco"]}}]}}],"category":["crepe"],"url":["http://example.com/crepe"]}}],"rels":{"tag":["http://en.wikipedia.org/wiki/crepe"],"self":["http://example.com/crepe"],"bookmark":["http://example.com/crepe"],"license":["http://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"]},"rel-urls":{"http://en.wikipedia.org/wiki/crepe":{"text":"crepe","rels":["tag"]},"http://example.com/crepe":{"text":"http://example.com/crepe","rels":["self","bookmark"]},"http://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License":{"text":"Creative Commons Attribution-ShareAlike License","rels":["license"]}}};
it('vcard', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/includes/hcarditemref
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('includes', function() {
var htmlFragment = "<div class=\"vcard\" itemref=\"mozilla-org mozilla-adr\">\n <span class=\"name\">Brendan Eich</span>\n</div>\n<div class=\"vcard\" itemref=\"mozilla-org mozilla-adr\">\n <span class=\"name\">Mitchell Baker</span>\n</div>\n\n<p id=\"mozilla-org\" class=\"org\">Mozilla</p>\n<p id=\"mozilla-adr\" class=\"adr\">\n <span class=\"street-address\">665 3rd St.</span> \n <span class=\"extended-address\">Suite 207</span> \n <span class=\"locality\">San Francisco</span>, \n <span class=\"region\">CA</span> \n <span class=\"postal-code\">94107</span> \n <span class=\"country-name\">U.S.A.</span> \n</p>";
var expected = {"items":[{"type":["h-card"],"properties":{"org":["Mozilla"],"adr":[{"value":"665 3rd St. \n Suite 207 \n San Francisco, \n CA \n 94107 \n U.S.A.","type":["h-adr"],"properties":{"street-address":["665 3rd St."],"extended-address":["Suite 207"],"locality":["San Francisco"],"region":["CA"],"postal-code":["94107"],"country-name":["U.S.A."]}}]}},{"type":["h-card"],"properties":{"org":["Mozilla"],"adr":[{"value":"665 3rd St. \n Suite 207 \n San Francisco, \n CA \n 94107 \n U.S.A.","type":["h-adr"],"properties":{"street-address":["665 3rd St."],"extended-address":["Suite 207"],"locality":["San Francisco"],"region":["CA"],"postal-code":["94107"],"country-name":["U.S.A."]}}]}},{"type":["h-adr"],"properties":{"street-address":["665 3rd St."],"extended-address":["Suite 207"],"locality":["San Francisco"],"region":["CA"],"postal-code":["94107"],"country-name":["U.S.A."]}}],"rels":{},"rel-urls":{}};
it('hcarditemref', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/includes/heventitemref
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('includes', function() {
var htmlFragment = "<div class=\"vevent\" itemref=\"io-session07\">\n <span class=\"name\">Monetizing Android Apps</span> - spaekers: \n <span class=\"speaker\">Chrix Finne</span>, \n <span class=\"speaker\">Kenneth Lui</span> - \n <span itemref=\"io-location\" class=\"location adr\">\n <span class=\"extended-address\">Room 10</span>\n </span> \n</div>\n<div class=\"vevent\" itemref=\"io-session07\">\n <span class=\"name\">New Low-Level Media APIs in Android</span> - spaekers: \n <span class=\"speaker\">Dave Burke</span> -\n <span itemref=\"io-location\" class=\"location adr\">\n <span class=\"extended-address\">Room 11</span>\n </span> \n</div>\n\n<p id=\"io-session07\">\n Session 01 is between: \n <time class=\"dtstart\" datetime=\"2012-06-27T15:45:00-0800\">3:45PM</time> to \n <time class=\"dtend\" datetime=\"2012-06-27T16:45:00-0800\">4:45PM</time> \n</p> \n<p id=\"io-location\">\n <span class=\"extended-address\">Moscone Center</span>, \n <span class=\"locality\">San Francisco</span> \n</p>";
var expected = {"items":[{"type":["h-event"],"properties":{"location":[{"value":"Room 10\n \n Moscone Center, \n San Francisco","type":["h-adr"],"properties":{"extended-address":["Room 10","Moscone Center"],"locality":["San Francisco"]}}],"start":["2012-06-27 15:45:00-08:00"],"end":["2012-06-27 16:45:00-08:00"]}},{"type":["h-event"],"properties":{"location":[{"value":"Room 11\n \n Moscone Center, \n San Francisco","type":["h-adr"],"properties":{"extended-address":["Room 11","Moscone Center"],"locality":["San Francisco"]}}],"start":["2012-06-27 15:45:00-08:00"],"end":["2012-06-27 16:45:00-08:00"]}}],"rels":{},"rel-urls":{}};
it('heventitemref', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/includes/hyperlink
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('includes', function() {
var htmlFragment = "<div class=\"vcard\">\n <span class=\"name\">Ben Ward</span>\n <a class=\"include\" href=\"#twitter\">Twitter</a>\n</div>\n<div class=\"vcard\">\n <span class=\"name\">Dan Webb</span>\n <a class=\"include\" href=\"#twitter\">Twitter</a>\n</div>\n\n<div id=\"twitter\">\n <p class=\"org\">Twitter</p>\n <p class=\"adr\">\n <span class=\"street-address\">1355 Market St</span>,\n <span class=\"locality\">San Francisco</span>, \n <span class=\"region\">CA</span>\n <span class=\"postal-code\">94103</span>\n </p>\n</div>";
var expected = {"items":[{"type":["h-card"],"properties":{"org":["Twitter"],"adr":[{"value":"1355 Market St,\n San Francisco, \n CA\n 94103","type":["h-adr"],"properties":{"street-address":["1355 Market St"],"locality":["San Francisco"],"region":["CA"],"postal-code":["94103"]}}]}},{"type":["h-card"],"properties":{"org":["Twitter"],"adr":[{"value":"1355 Market St,\n San Francisco, \n CA\n 94103","type":["h-adr"],"properties":{"street-address":["1355 Market St"],"locality":["San Francisco"],"region":["CA"],"postal-code":["94103"]}}]}},{"type":["h-adr"],"properties":{"street-address":["1355 Market St"],"locality":["San Francisco"],"region":["CA"],"postal-code":["94103"]}}],"rels":{},"rel-urls":{}};
it('hyperlink', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/includes/object
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('includes', function() {
var htmlFragment = "<div class=\"vevent\">\n <span class=\"name\">HTML5 & CSS3 latest features in action!</span> - \n <span class=\"speaker\">David Rousset</span> -\n <time class=\"dtstart\" datetime=\"2012-10-30T11:45:00-08:00\">Tue 11:45am</time>\n <object data=\"#buildconf\" class=\"include\" type=\"text/html\" height=\"0\" width=\"0\"></object>\n</div>\n<div class=\"vevent\">\n <span class=\"name\">Building High-Performing JavaScript for Modern Engines</span> -\n <span class=\"speaker\">John-David Dalton</span> and \n <span class=\"speaker\">Amanda Silver</span> -\n <time class=\"dtstart\" datetime=\"2012-10-31T11:15:00-08:00\">Wed 11:15am</time>\n <object data=\"#buildconf\" class=\"include\" type=\"text/html\" height=\"0\" width=\"0\"></object>\n</div>\n\n\n<div id=\"buildconf\">\n <p class=\"summary\">Build Conference</p>\n <p class=\"location adr\">\n <span class=\"locality\">Redmond</span>, \n <span class=\"region\">Washington</span>, \n <span class=\"country-name\">USA</span>\n </p>\n</div>";
var expected = {"items":[{"type":["h-event"],"properties":{"start":["2012-10-30 11:45:00-08:00"],"name":["Build Conference"],"location":[{"value":"Redmond, \n Washington, \n USA","type":["h-adr"],"properties":{"locality":["Redmond"],"region":["Washington"],"country-name":["USA"]}}]}},{"type":["h-event"],"properties":{"start":["2012-10-31 11:15:00-08:00"],"name":["Build Conference"],"location":[{"value":"Redmond, \n Washington, \n USA","type":["h-adr"],"properties":{"locality":["Redmond"],"region":["Washington"],"country-name":["USA"]}}]}},{"type":["h-adr"],"properties":{"locality":["Redmond"],"region":["Washington"],"country-name":["USA"]}}],"rels":{},"rel-urls":{}};
it('object', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v1/includes/table
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('includes', function() {
var htmlFragment = "<meta charset=\"utf-8\">\n<table>\n <tr>\n <th id=\"org\"><a class=\"url org\" href=\"http://dev.opera.com/\">Opera</a></th>\n </tr>\n <tr>\n <td class=\"vcard\" headers=\"org\"><span class=\"fn\">Chris Mills</span></td>\n </tr>\n <tr>\n <td class=\"vcard\" headers=\"org\"><span class=\"fn\">Erik Möller</span></td>\n </tr>\n </table>";
var expected = {"items":[{"type":["h-card"],"properties":{"name":["Chris Mills"],"url":["http://dev.opera.com/"],"org":["Opera"]}},{"type":["h-card"],"properties":{"name":["Erik Möller"],"url":["http://dev.opera.com/"],"org":["Opera"]}}],"rels":{},"rel-urls":{}};
it('table', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v2/h-adr/geo
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('h-adr', function() {
var htmlFragment = "<p class=\"h-adr\">\n <span class=\"p-name\">Bricklayer's Arms</span>\n <span class=\"p-label\"> \n <span class=\"p-street-address\">3 Charlotte Road</span>, \n <span class=\"p-locality\">City of London</span>, \n <span class=\"p-postal-code\">EC2A 3PE</span>, \n <span class=\"p-country-name\">UK</span> \n </span> \n Geo:(<span class=\"p-geo\">51.526421;-0.081067</span>) \n</p>";
var expected = {"items":[{"type":["h-adr"],"properties":{"name":["Bricklayer's Arms"],"label":["3 Charlotte Road, \n City of London, \n EC2A 3PE, \n UK"],"street-address":["3 Charlotte Road"],"locality":["City of London"],"postal-code":["EC2A 3PE"],"country-name":["UK"],"geo":["51.526421;-0.081067"]}}],"rels":{},"rel-urls":{}};
it('geo', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v2/h-adr/geourl
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('h-adr', function() {
var htmlFragment = "<p class=\"h-adr\">\n <a class=\"p-name u-geo\" href=\"geo:51.526421;-0.081067;crs=wgs84;u=40\">Bricklayer's Arms</a>, \n <span class=\"p-locality\">London</span> \n</p>";
var expected = {"items":[{"type":["h-adr"],"properties":{"name":["Bricklayer's Arms"],"geo":["geo:51.526421;-0.081067;crs=wgs84;u=40"],"locality":["London"],"url":["geo:51.526421;-0.081067;crs=wgs84;u=40"]}}],"rels":{},"rel-urls":{}};
it('geourl', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

View File

@ -0,0 +1,27 @@
/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.24
Mocha integration test from: microformats-v2/h-adr/justaname
The test was built on Fri Sep 25 2015 13:26:26 GMT+0100 (BST)
*/
assert = chai.assert;
describe('h-adr', function() {
var htmlFragment = "<p class=\"h-adr\">665 3rd St. Suite 207 San Francisco, CA 94107 U.S.A.</p>";
var expected = {"items":[{"type":["h-adr"],"properties":{"name":["665 3rd St. Suite 207 San Francisco, CA 94107 U.S.A."]}}],"rels":{},"rel-urls":{}};
it('justaname', function(){
var doc, dom, node, options, parser, found;
dom = new DOMParser();
doc = dom.parseFromString( htmlFragment, 'text/html' );
options ={
'document': doc,
'node': doc,
'baseUrl': 'http://example.com',
'dateFormat': 'html5'
};
found = Microformats.get( options );
assert.deepEqual(found, expected);
});
});

Some files were not shown because too many files have changed in this diff Show More