Skip to content

Commit

Permalink
Added test.coffee.
Browse files Browse the repository at this point in the history
  • Loading branch information
oozcitak committed May 1, 2011
1 parent 7a7de8c commit 057b5e3
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
lib/
test/test.js
9 changes: 7 additions & 2 deletions Makefile
@@ -1,13 +1,18 @@
dev:
@test `which coffee` || echo 'You need to have CoffeeScript installed.'
@coffee test/test.coffee

release:
@rm -fr lib/
@test `which coffee` || echo 'You need to have CoffeeScript installed.'
@coffee -c -o lib src/*.coffee
@coffee -c -o test test/test.coffee

publish: dev
publish: release
@test `which npm` || echo 'You need to have npm installed.'
npm publish
@rm -fr lib/

test: dev
test: release
@test `which node` || echo 'You need to have node-js installed.'
@node ./test/test.js
30 changes: 30 additions & 0 deletions test/test.coffee
@@ -0,0 +1,30 @@
xml = '<root>' +
'<xmlbuilder for="node-js">' +
'<!-- CoffeeScript is awesome. -->' +
'<repo type="git">git://github.com/oozcitak/xmlbuilder-js.git</repo>' +
'</xmlbuilder>' +
'<test escaped="chars &lt;&gt;&apos;&quot;&amp;">complete 100%</test>' +
'<cdata><![CDATA[<test att="val">this is a test</test>]]></cdata>' +
'</root>'

builder = require '../src/index.coffee'
builder.begin('root')
.ele('xmlbuilder')
.att('for', 'node-js')
.com('CoffeeScript is awesome.')
.ele('repo')
.att('type', 'git')
.txt('git://github.com/oozcitak/xmlbuilder-js.git')
.up()
.up()
.ele('test')
.att('escaped', 'chars <>\'"&')
.txt('complete 100%')
.up()
.ele('cdata')
.cdata('<test att="val">this is a test</test>')

assert = require('assert')
test = builder.toString()
assert.strictEqual(xml, test)

39 changes: 9 additions & 30 deletions test/test.js
@@ -1,30 +1,9 @@
var xml = '<root>' +
'<xmlbuilder for="node-js">' +
'<!-- CoffeeScript is awesome. -->' +
'<repo type="git">git://github.com/oozcitak/xmlbuilder-js.git</repo>' +
'</xmlbuilder>' +
'<test escaped="chars &lt;&gt;&apos;&quot;&amp;">complete 100%</test>' +
'<cdata><![CDATA[<test att="val">this is a test</test>]]></cdata>' +
'</root>';

var builder = require('../lib/index.js');
builder.begin('root')
.ele('xmlbuilder')
.att('for', 'node-js')
.com('CoffeeScript is awesome.')
.ele('repo')
.att('type', 'git')
.txt('git://github.com/oozcitak/xmlbuilder-js.git')
.up()
.up()
.ele('test')
.att('escaped', 'chars <>\'"&')
.txt('complete 100%')
.up()
.ele('cdata')
.cdata('<test att="val">this is a test</test>');

var assert = require('assert');
var test = builder.toString();
assert.strictEqual(xml, test);

(function() {
var assert, builder, test, xml;
xml = '<root>' + '<xmlbuilder for="node-js">' + '<!-- CoffeeScript is awesome. -->' + '<repo type="git">git://github.com/oozcitak/xmlbuilder-js.git</repo>' + '</xmlbuilder>' + '<test escaped="chars &lt;&gt;&apos;&quot;&amp;">complete 100%</test>' + '<cdata><![CDATA[<test att="val">this is a test</test>]]></cdata>' + '</root>';
builder = require('../src/index.coffee');
builder.begin('root').ele('xmlbuilder').att('for', 'node-js').com('CoffeeScript is awesome.').ele('repo').att('type', 'git').txt('git://github.com/oozcitak/xmlbuilder-js.git').up().up().ele('test').att('escaped', 'chars <>\'"&').txt('complete 100%').up().ele('cdata').cdata('<test att="val">this is a test</test>');
assert = require('assert');
test = builder.toString();
assert.strictEqual(xml, test);
}).call(this);

0 comments on commit 057b5e3

Please sign in to comment.