codescape
Version:
A node tool to escape characters to html entities or uri entities and to convert tabs to spaces so that your code indentation and symbols does not change in blogs or websites.
37 lines (35 loc) • 1.4 kB
JavaScript
var codescape = require('../'),
expect = require('expect.js'),
path = require('path') ;
describe('codescape', function(){
describe('arguments not specified', function(){
it('should return nothing when arguments are not fulfilling', function(){
var result = codescape() ;
expect(result).to.be(null) ;
})
});
describe('given string', function(){
it('should return escaped string when selector is not given', function(){
var string = '<pre>var x= 10 ;</pre>' ;
var resultString = '<pre>var x= 10 ;</pre>' ;
var escapedString = codescape({'string': string}) ;
expect(escapedString).to.be(resultString) ;
}) ;
it('should return escaped string when selector is given', function(){
var string = '<p><b>Heading</b><code class="print"><script src="something.js"/></code></p>' ;
var selector = 'p code.print'
var resultString = '<p><b>Heading</b><code class="print"><script src="something.js"/></code></p>' ;
var escapedString = codescape({'string': string, 'selector':selector}) ;
expect(escapedString).to.be(resultString) ;
}) ;
});
describe('given file', function(){
it('should escape whole file if selector is not given', function(){
var filename = 'test/input.html' ;
var callback = function(result){
expect(result).to.be(false) ;
} ;
codescape({'filename': filename, 'callback':callback}) ;
});
});
}) ;