Commit 8587dee6 authored by Björn Bartels's avatar Björn Bartels

PATLAB-7 added more tests

parent cc9df755
......@@ -23,5 +23,24 @@
</div>
</section>
<!-- Matomo -->
<script type="text/javascript">
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["setCookieDomain", "*.demo.patternlibrary.bjoernbartels.earth"]);
_paq.push(["setDomains", ["*.demo.patternlibrary.bjoernbartels.earth","*.demo.patternlibrary.net","*.demo.patternlibrary.org"]]);
_paq.push(["enableCrossDomainLinking"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//analytics.bjoernbartels.earth/piwik/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '7']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//analytics.bjoernbartels.earth/piwik/piwik.php?idsite=7&rec=1" style="border:0;" alt="" /></p></noscript>
<!-- End Matomo Code -->
</body>
</html>
\ No newline at end of file
......@@ -16,4 +16,4 @@
})();
</script>
<noscript><p><img src="//analytics.bjoernbartels.earth/piwik/piwik.php?idsite=7&rec=1" style="border:0;" alt="" /></p></noscript>
<!-- End Matomo Code -->
\ No newline at end of file
<!-- End Matomo Code -->
......@@ -35,7 +35,7 @@ module.exports.search = function(items, link) {
function getGitInfo(value, config, pl) {
if (!fs.existsSync(value)) return false;
var logFormatYaml =
'- date: \'%cd\''+'%n'+
' timestamp: %ct'+'%n'+
......@@ -88,16 +88,17 @@ function getGitInfo(value, config, pl) {
function processTree(tree, config) {
var logs = {};
for (var i in tree.log.data) {
var obj = tree.log.data[i];
var logdate = obj.date;
if (!logs[logdate]) { logs[logdate] = []; }
logs[logdate].push(obj);
if (tree && tree.log) {
for (var i in tree.log.data) {
var obj = tree.log.data[i];
var logdate = obj.date;
if (!logs[logdate]) { logs[logdate] = []; }
logs[logdate].push(obj);
}
tree.log.data = logs;
}
tree.log.data = logs;
return tree;
}
......
......@@ -28,7 +28,7 @@ module.exports.search = function(items, link) {
function getPatternSpecs(value, config, pl) {
if (!fs.existsSync(value)) return false;
var sourceFile = frontMatter(fs.readFileSync(value).toString());
//var sourceFile = frontMatter(fs.readFileSync(value).toString());
return {};
}
......
......@@ -134,7 +134,7 @@ describe('Patternlibrary instanciation and configuration:', function() {
describe('Patternlibrary "example" adapter:', () => {
let adapter = require('../lib/adapters/example.js');
let patternlibraryOptions = {
/*let patternlibraryOptions = {
verbose : false,
dest : FIXTURES + 'example/build',
root : FIXTURES + 'example/pages/',
......@@ -142,7 +142,8 @@ describe('Patternlibrary instanciation and configuration:', function() {
partials: FIXTURES + 'example/partials/',
testing : true
};
var p = new Patternlibrary.Patternlibrary(patternlibraryOptions);
var p = new Patternlibrary.Patternlibrary(patternlibraryOptions);*/
var p = new Patternlibrary.Patternlibrary();
it('retrieves example\'s source-code from file', function (done) {
......@@ -241,7 +242,6 @@ describe('Patternlibrary instanciation and configuration:', function() {
'test/fixtures/adapters/example/partials/atoms/link/module.js',
{},
( a, b ) => {
console.log(b);
expect(b).to.be.an('object')
.that.is.not.empty;
......@@ -272,7 +272,6 @@ describe('Patternlibrary instanciation and configuration:', function() {
'test/fixtures/adapters/example/partials/atoms/link/module_no_defaults.js',
{},
( a, b ) => {
console.log(b);
expect(b).to.be.an('object')
.that.is.not.empty;
......@@ -283,6 +282,123 @@ describe('Patternlibrary instanciation and configuration:', function() {
);
});
});
describe('Patternlibrary "changelog" adapter:', () => {
let adapter = require('../lib/adapters/changelog.js');
var p = new Patternlibrary.Patternlibrary();
it('retrieves example\'s source-code from file', function (done) {
adapter(
'test/fixtures/adapters/example/partials/atoms/link/changelog.md',
{},
( a, b ) => {
expect(b).to.be.a('string');
done();
},
p
);
});
it('returns flase if file is not readable/does not exist', function (done) {
adapter(
'test/fixtures/adapters/example/partials/atoms/link/changelog_not_found.md',
{},
( a, b ) => {
expect(b).to.equal(false);
done();
},
p
);
});
it('search method returns empty result', function () {
let result = adapter.search();
expect(result).to.be.empty;
});
});
describe('Patternlibrary "tests" adapter:', () => {
let adapter = require('../lib/adapters/tests.js');
it('retrieves test-results from test-file', function (done) {
adapter(
'test/fixtures/adapters/example/partials/atoms/link/test.js',
{},
( a, b ) => {
expect(b).to.be.a('object');
done();
}
);
});
it('returns flase if file is not readable/does not exist', function (done) {
adapter(
'test/fixtures/adapters/example/partials/atoms/link/test_not_found.js',
{},
( a, b ) => {
expect(b).to.equal(false);
done();
}
);
});
it('search method returns empty result', function () {
let result = adapter.search();
expect(result).to.be.empty;
});
});
describe('Patternlibrary "gitinfo" adapter:', () => {
let adapter = require('../lib/adapters/gitinfo.js');
var p = new Patternlibrary.Patternlibrary();
it('retrieves git-info from file', function (done) {
adapter(
'test/fixtures/adapters/example/partials/atoms/link/atom-link.html',
{},
( a, b ) => {
expect(b).to.be.a('object');
done();
},
p
);
});
it('returns flase if file is not readable/does not exist', function (done) {
adapter(
'test/fixtures/adapters/example/partials/atoms/link/file_not_found.html',
{},
( a, b ) => {
expect(b).to.equal(false);
done();
},
p
);
});
it('search method returns empty result', function () {
let result = adapter.search();
expect(result).to.be.empty;
});
});
......
import Patternlibrary from '..';
import equal from 'assert-dir-equal';
import rimraf from 'rimraf';
import mkdirp from 'mkdirp';
var expect = require('chai').expect;
var $md = require('../lib/vendor/markdown-it.js');
var stripHtml = require('striptags');
describe('Markdown-It plugin helpers', function () {
it('renders highlighted code block with given language', function () {
let codeblock = ["```html_example", "\n",
'<div class="galaxy"><div>',
"```"].join("\n");
let result = $md.render(codeblock);
console.log(result);
expect(result).to.be.a('string');
});
it('renders highlighted code block with no language', function () {
let codeblock = ["```", "\n",
'<div class="galaxy"><div>',
"```"].join("\n");
let result = $md.render(codeblock);
console.log(result);
expect(result).to.be.a('string');
});
it('renders highlighted code block with faulty indicator', function () {
let codeblock = ["```_example", "\n",
'<div class="galaxy"><div>',
"```"].join("\n");
let result = $md.render(codeblock);
console.log(result);
expect(result).to.be.a('string');
});
});
\ No newline at end of file
import Patternlibrary from '..';
import equal from 'assert-dir-equal';
import rimraf from 'rimraf';
import mkdirp from 'mkdirp';
var expect = require('chai').expect;
var $md = require('../lib/vendor/markdown-it.js');
var stripHtml = require('striptags');
describe('Markdown-It plugin helpers', function () {
it('renders highlighted code block with given language', function () {
let codeblock = ["```html_example", "\n",
'<div class="galaxy"><div>',
"```"].join("\n");
let result = $md.render(codeblock);
console.log(result);
expect(result).to.be.a('string');
});
it('renders highlighted code block with no language', function () {
let codeblock = ["```", "\n",
'<div class="galaxy"><div>',
"```"].join("\n");
let result = $md.render(codeblock);
console.log(result);
expect(result).to.be.a('string');
});
it('renders highlighted code block with faulty indicator', function () {
let codeblock = ["```_example", "\n",
'<div class="galaxy"><div>',
"```"].join("\n");
let result = $md.render(codeblock);
console.log(result);
expect(result).to.be.a('string');
});
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment