Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
christiaanwesterbeek committed Nov 28, 2014
1 parent 90dba9b commit bb63e5f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
npm-debug.log
node_modules
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@
"bugs": {
"url" : "https://github.com/devotis/node-extjs-custom/issues",
"email" : "[email protected]"
},
"devDependencies": {
"mocha": "2.0.x",
"should": "4.3.x"
}
}
45 changes: 45 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var should = require('should');

var Ext = require('../Ext');
Ext.Template = require('../Template');
Ext.XTemplate = require('../XTemplate');

var data = {
name: 'Don Griffin',
title: 'Senior Technomage',
company: 'Sencha Inc.',
drinks: ['Coffee', 'Water', 'More Coffee'],
kids: [
{ name: 'Aubrey', age: 17 },
{ name: 'Joshua', age: 13 },
{ name: 'Cale', age: 10 },
{ name: 'Nikol', age: 5 },
{ name: 'Solomon', age: 0 }
]
};

describe('Template', function() {
it('basic compiling should work', function() {
var tpl = new Ext.Template('Name: {0}, Age: {1}');
var html = tpl.apply(['John', 25]);
html.should.be.a.String.and.be.equal('Name: John, Age: 25')
});
});

describe('XTemplate', function() {
it('basic compiling should work', function() {
var tpl = new Ext.XTemplate(
'<p>Name: {name}</p>',
'<p>Title: {title}</p>',
'<p>Company: {company}</p>',
'<p>Kids: ',
'<tpl for="kids">', // interrogate the kids property within the data
'<p>{name}</p>',
'</tpl></p>'
);

var html = tpl.apply(data);
html.should.be.a.String.and.be.equal('<p>Name: Don Griffin</p><p>Title: Senior Technomage</p><p>Company: Sencha Inc.</p><p>Kids: <tpl for="kids"><p>Don Griffin</p></tpl></p>')
});
});

0 comments on commit bb63e5f

Please sign in to comment.