diff --git a/examples/.DS_Store b/examples/.DS_Store new file mode 100644 index 0000000..3678fe5 Binary files /dev/null and b/examples/.DS_Store differ diff --git a/examples/examples.js b/examples/examples.js index f4c7c21..d34e7b8 100644 --- a/examples/examples.js +++ b/examples/examples.js @@ -1,7 +1,7 @@ var Table = require('../src/table'); var colors = require('colors/safe'); - module.exports = function(runTest) { + module.exports = function(runTest,screenshot) { function it(name,fn) { var result = fn(); diff --git a/examples/screenshots/truncation-with-colors.png b/examples/screenshots/truncation-with-colors.png new file mode 100644 index 0000000..d14b9d2 Binary files /dev/null and b/examples/screenshots/truncation-with-colors.png differ diff --git a/lib/print-example.js b/lib/print-example.js index 8e5000a..10eb5cf 100644 --- a/lib/print-example.js +++ b/lib/print-example.js @@ -4,7 +4,7 @@ var expect = chai.expect; var colors = require('colors/safe'); var fs = require('fs'); -function runExample(fn,logName,logTable,logCode,logSeparator){ +function runExample(fn,logName,logTable,logCode,logSeparator,screenshot){ function printExample(name,makeTable,expected){ var code = makeTable.toString().split('\n').slice(1,-2).join('\n'); @@ -14,7 +14,7 @@ function runExample(fn,logName,logTable,logCode,logSeparator){ logSeparator('\n'); } - fn(printExample); + fn(printExample,screenshot); } function logExample(fn){ @@ -24,7 +24,8 @@ function logExample(fn){ }, console.log, console.log, - console.log + console.log, + identity ) } @@ -32,6 +33,10 @@ function stripColors(str){ return str.split( /\u001b\[(?:\d*;){0,5}\d*m/g).join(''); } +function identity(str){ + return str; +} + function mdExample(fn,file){ var buffer = []; @@ -65,7 +70,7 @@ function testExample(name,fn,expected){ function runTest(fn){ describe('@api Table', function () { - fn(testExample); + fn(testExample,identity); }); }