/*! * typographer * Copyright(c) 2011 Eugene Kalinin * MIT Licensed */ var tp = require('../typogr') , assert = require('assert'); describe('typogr', function() { it('amp tests', function() { ['One & two', 'One & two', 'One & two'].forEach( function (val) { assert.equal(tp.amp(val), 'One & two'); }); assert.equal(tp.amp('One & two'), 'One & two'); // It won't mess up & that are already wrapped, in entities or URLs assert.equal(tp.amp('One & two'), 'One & two'); assert.equal(tp.amp('“this” & that'), '“this” & that'); // It should ignore standalone amps that are in attributes assert.equal(tp.amp('xyz'), 'xyz'); // It should ignore amps inside script tags assert.equal(tp.amp(''), ''); }); it('ord tests', function() { assert.equal(tp.ord('1st'), '1st'); assert.equal(tp.ord('2nd'), '2nd'); assert.equal(tp.ord('3rd'), '3rd'); assert.equal(tp.ord('10th'), '10th'); assert.equal(tp.ord('37th'), '37th'); assert.equal(tp.ord('1000th'), '1000th'); // Make sure it does not happen within attributes assert.equal(tp.ord('1st'), '1st'); }); it('quotes tests', function() { assert.equal(tp.initQuotes('"With primes"'), '"With primes"'); assert.equal(tp.initQuotes("'With single primes'"), '\'With single primes\''); assert.equal(tp.initQuotes('"With primes and a link"'), '"With primes and a link"'); assert.equal(tp.initQuotes('“With smartypanted quotes”'), 'With smartypanted quotes”'); assert.equal(tp.initQuotes('

‘With single primes ...

'), '

With single primes ...

'); assert.equal(tp.initQuotes('

“Jayhawks” & KU fans ...

'), '

Jayhawks” & KU fans ...

'); }); it('widont tests', function() { assert.equal(tp.widont('A very simple test'), 'A very simple test'); // Single word items shouldn't be changed assert.equal(tp.widont('Test'), 'Test'); assert.equal(tp.widont(' Test'), ' Test'); assert.equal(tp.widont('