From 2afbcf4e7d000d99fdbc582d7113684ee00e80cc Mon Sep 17 00:00:00 2001 From: yo mama Date: Fri, 20 Mar 2015 17:33:43 -0700 Subject: first --- node_modules/ejs/test/ejs.js | 265 +++++++++++++++++++++ node_modules/ejs/test/fixtures/backslash.ejs | 1 + node_modules/ejs/test/fixtures/backslash.html | 1 + node_modules/ejs/test/fixtures/comments.ejs | 5 + node_modules/ejs/test/fixtures/comments.html | 4 + node_modules/ejs/test/fixtures/double-quote.ejs | 1 + node_modules/ejs/test/fixtures/double-quote.html | 1 + node_modules/ejs/test/fixtures/error.ejs | 5 + node_modules/ejs/test/fixtures/error.out | 8 + node_modules/ejs/test/fixtures/fail.ejs | 1 + node_modules/ejs/test/fixtures/include.css.ejs | 1 + node_modules/ejs/test/fixtures/include.css.html | 3 + node_modules/ejs/test/fixtures/include.ejs | 5 + node_modules/ejs/test/fixtures/include.html | 9 + .../ejs/test/fixtures/includes/menu-item.ejs | 1 + .../ejs/test/fixtures/includes/menu/item.ejs | 1 + node_modules/ejs/test/fixtures/menu.ejs | 11 + node_modules/ejs/test/fixtures/menu.html | 3 + node_modules/ejs/test/fixtures/messed.ejs | 1 + node_modules/ejs/test/fixtures/messed.html | 1 + node_modules/ejs/test/fixtures/newlines.ejs | 5 + node_modules/ejs/test/fixtures/newlines.html | 9 + node_modules/ejs/test/fixtures/no.newlines.ejs | 5 + node_modules/ejs/test/fixtures/no.newlines.html | 5 + node_modules/ejs/test/fixtures/para.ejs | 1 + node_modules/ejs/test/fixtures/pet.ejs | 1 + node_modules/ejs/test/fixtures/single-quote.ejs | 1 + node_modules/ejs/test/fixtures/single-quote.html | 1 + node_modules/ejs/test/fixtures/style.css | 3 + node_modules/ejs/test/fixtures/user.ejs | 1 + 30 files changed, 360 insertions(+) create mode 100644 node_modules/ejs/test/ejs.js create mode 100644 node_modules/ejs/test/fixtures/backslash.ejs create mode 100644 node_modules/ejs/test/fixtures/backslash.html create mode 100644 node_modules/ejs/test/fixtures/comments.ejs create mode 100644 node_modules/ejs/test/fixtures/comments.html create mode 100644 node_modules/ejs/test/fixtures/double-quote.ejs create mode 100644 node_modules/ejs/test/fixtures/double-quote.html create mode 100644 node_modules/ejs/test/fixtures/error.ejs create mode 100644 node_modules/ejs/test/fixtures/error.out create mode 100644 node_modules/ejs/test/fixtures/fail.ejs create mode 100644 node_modules/ejs/test/fixtures/include.css.ejs create mode 100644 node_modules/ejs/test/fixtures/include.css.html create mode 100644 node_modules/ejs/test/fixtures/include.ejs create mode 100644 node_modules/ejs/test/fixtures/include.html create mode 100644 node_modules/ejs/test/fixtures/includes/menu-item.ejs create mode 100644 node_modules/ejs/test/fixtures/includes/menu/item.ejs create mode 100644 node_modules/ejs/test/fixtures/menu.ejs create mode 100644 node_modules/ejs/test/fixtures/menu.html create mode 100644 node_modules/ejs/test/fixtures/messed.ejs create mode 100644 node_modules/ejs/test/fixtures/messed.html create mode 100644 node_modules/ejs/test/fixtures/newlines.ejs create mode 100644 node_modules/ejs/test/fixtures/newlines.html create mode 100644 node_modules/ejs/test/fixtures/no.newlines.ejs create mode 100644 node_modules/ejs/test/fixtures/no.newlines.html create mode 100644 node_modules/ejs/test/fixtures/para.ejs create mode 100644 node_modules/ejs/test/fixtures/pet.ejs create mode 100644 node_modules/ejs/test/fixtures/single-quote.ejs create mode 100644 node_modules/ejs/test/fixtures/single-quote.html create mode 100644 node_modules/ejs/test/fixtures/style.css create mode 100644 node_modules/ejs/test/fixtures/user.ejs (limited to 'node_modules/ejs/test') diff --git a/node_modules/ejs/test/ejs.js b/node_modules/ejs/test/ejs.js new file mode 100644 index 0000000..1c58c1c --- /dev/null +++ b/node_modules/ejs/test/ejs.js @@ -0,0 +1,265 @@ +/** + * Module dependencies. + */ + +var ejs = require('..') + , fs = require('fs') + , read = fs.readFileSync + , assert = require('should'); + +/** + * Load fixture `name`. + */ + +function fixture(name) { + return read('test/fixtures/' + name, 'utf8').replace(/\r/g, ''); +} + +/** + * User fixtures. + */ + +var users = []; +users.push({ name: 'tobi' }); +users.push({ name: 'loki' }); +users.push({ name: 'jane' }); + +describe('ejs.compile(str, options)', function(){ + it('should compile to a function', function(){ + var fn = ejs.compile('

yay

'); + fn().should.equal('

yay

'); + }) + + it('should throw if there are syntax errors', function(){ + try { + ejs.compile(fixture('fail.ejs')); + } catch (err) { + err.message.should.include('compiling ejs'); + + try { + ejs.compile(fixture('fail.ejs'), { filename: 'fail.ejs' }); + } catch (err) { + err.message.should.include('fail.ejs'); + return; + } + } + + assert(false, 'compiling a file with invalid syntax should throw an exception'); + }) + + it('should allow customizing delimiters', function(){ + var fn = ejs.compile('

{= name }

', { open: '{', close: '}' }); + fn({ name: 'tobi' }).should.equal('

tobi

'); + + var fn = ejs.compile('

::= name ::

', { open: '::', close: '::' }); + fn({ name: 'tobi' }).should.equal('

tobi

'); + + var fn = ejs.compile('

(= name )

', { open: '(', close: ')' }); + fn({ name: 'tobi' }).should.equal('

tobi

'); + }) + + it('should default to using ejs.open and ejs.close', function(){ + ejs.open = '{'; + ejs.close = '}'; + var fn = ejs.compile('

{= name }

'); + fn({ name: 'tobi' }).should.equal('

tobi

'); + + var fn = ejs.compile('

|= name |

', { open: '|', close: '|' }); + fn({ name: 'tobi' }).should.equal('

tobi

'); + delete ejs.open; + delete ejs.close; + }) + + it('should have a working client option', function(){ + var fn = ejs.compile('

<%= foo %>

', { client: true }); + var str = fn.toString(); + eval('var preFn = ' + str); + preFn({ foo: 'bar' }).should.equal('

bar

'); + }) +}) + +describe('ejs.render(str, options)', function(){ + it('should render the template', function(){ + ejs.render('

yay

') + .should.equal('

yay

'); + }) + + it('should accept locals', function(){ + ejs.render('

<%= name %>

', { name: 'tobi' }) + .should.equal('

tobi

'); + }) +}) + +describe('ejs.renderFile(path, options, fn)', function(){ + it('should render a file', function(done){ + ejs.renderFile('test/fixtures/para.ejs', function(err, html){ + if (err) return done(err); + html.should.equal('

hey

'); + done(); + }); + }) + + it('should accept locals', function(done){ + var options = { name: 'tj', open: '{', close: '}' }; + ejs.renderFile('test/fixtures/user.ejs', options, function(err, html){ + if (err) return done(err); + html.should.equal('

tj

'); + done(); + }); + }) + + it('should not catch err threw by callback', function(done){ + var options = { name: 'tj', open: '{', close: '}' }; + var counter = 0; + try { + ejs.renderFile('test/fixtures/user.ejs', options, function(err, html){ + counter++; + if (err) { + err.message.should.not.equal('Exception in callback'); + return done(err); + } + throw new Error('Exception in callback'); + }); + } catch (err) { + counter.should.equal(1); + err.message.should.equal('Exception in callback'); + done(); + } + }) +}) + +describe('<%=', function(){ + it('should escape', function(){ + ejs.render('<%= name %>', { name: '