UNPKG

pullquote

Version:

Add pull quotes to your posts

58 lines (46 loc) 1.69 kB
var tests , assert = require('assert') , fs = require('fs') , path = require('path') , diff = require('diff') , clc = require('cli-color') , pullquote = require('../lib/pullquote.js') , prettyDiff = function (actual, expected) { var lines = diff.diffWords(actual, expected) , buff = []; for(var i=0, ii=lines.length; i<ii; i++) { if(lines[i].added) { buff.push('+' + clc.green(lines[i].value)); } else if(lines[i].removed) { buff.push('+' + clc.red(lines[i].value)); } else { buff.push(lines[i].value); } } return buff.join('\n'); }; tests = { "preserves normal text (index)": function () { var actual = pullquote.index('nothing') , expected = 'nothing'; assert.strictEqual(actual, expected, 'normal text is preserved'); } , "preserves normal text (show)": function () { var actual = pullquote.show('nothing') , expected = 'nothing'; assert.strictEqual(actual, expected, 'normal text is preserved'); } , "pullquote": function () { var actual = pullquote.show('a{% pullquote %}something {&quot;pullme&quot;} else{% endpullquote %}b') , expected = 'a<span class="pullquote-right" data-pullquote="pullme">something pullme else</span>b'; assert.strictEqual(actual, expected, 'text was pulled'); } , "pullquote (shorttag)": function () { var actual = pullquote.show('a{%pullquote%}something {&quot;pullme&quot;} else{%endpullquote%}b') , expected = 'a<span class="pullquote-right" data-pullquote="pullme">something pullme else</span>b'; assert.strictEqual(actual, expected, 'text was pulled'); } }; module.exports = tests;