Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We need version 0.2.3 of the zap test runner as it supports CoffeeScript
- Loading branch information
1 parent
47fb32a
commit f0685b8
Showing
3 changed files
with
53 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,6 @@ | |
"sax" : ">=0.1.1" | ||
}, | ||
"devDependencies" : { | ||
"zap" : ">=0.2.0" | ||
"zap" : ">=0.2.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# use zap to run tests, it also detects CoffeeScript files | ||
xml2js = require('../lib/xml2js') | ||
fs = require('fs') | ||
sys = require('sys') | ||
assert = require('assert') | ||
|
||
module.exports = | ||
'test default parse': (test) -> | ||
x2js = new xml2js.Parser() | ||
x2js.addListener 'end', (r) -> | ||
console.log 'Result object: ' + sys.inspect(r, false, 10) | ||
assert.equal r['chartest']['@']['desc'], 'Test for CHARs' | ||
assert.equal r['chartest']['#'], 'Character data here!' | ||
assert.equal r['cdatatest']['@']['desc'], 'Test for CDATA' | ||
assert.equal r['cdatatest']['@']['misc'], 'true' | ||
assert.equal r['cdatatest']['#'], 'CDATA here!' | ||
assert.equal r['nochartest']['@']['desc'], 'No data' | ||
assert.equal r['nochartest']['@']['misc'], 'false' | ||
assert.equal r['listtest']['item'][0]['#'], 'This is character data!' | ||
assert.equal r['listtest']['item'][0]['subitem'][0], 'Foo(1)' | ||
assert.equal r['listtest']['item'][0]['subitem'][1], 'Foo(2)' | ||
assert.equal r['listtest']['item'][0]['subitem'][2], 'Foo(3)' | ||
assert.equal r['listtest']['item'][0]['subitem'][3], 'Foo(4)' | ||
assert.equal r['listtest']['item'][1], 'Qux.' | ||
assert.equal r['listtest']['item'][2], 'Quux.' | ||
test.finish() | ||
|
||
fs.readFile __dirname + '/fixtures/sample.xml', (err, data) -> | ||
x2js.parseString data | ||
|
||
'test parse EXPLICIT_CHARKEY': (test) -> | ||
x2js = new xml2js.Parser() | ||
x2js.EXPLICIT_CHARKEY = true | ||
x2js.addListener 'end', (r) -> | ||
assert.equal r['chartest']['@']['desc'], 'Test for CHARs' | ||
assert.equal r['chartest']['#'], 'Character data here!' | ||
assert.equal r['cdatatest']['@']['desc'], 'Test for CDATA' | ||
assert.equal r['cdatatest']['@']['misc'], 'true' | ||
assert.equal r['cdatatest']['#'], 'CDATA here!' | ||
assert.equal r['nochartest']['@']['desc'], 'No data' | ||
assert.equal r['nochartest']['@']['misc'], 'false' | ||
assert.equal r['listtest']['item'][0]['#'], 'This is character data!' | ||
assert.equal r['listtest']['item'][0]['subitem'][0]['#'], 'Foo(1)' | ||
assert.equal r['listtest']['item'][0]['subitem'][1]['#'], 'Foo(2)' | ||
assert.equal r['listtest']['item'][0]['subitem'][2]['#'], 'Foo(3)' | ||
assert.equal r['listtest']['item'][0]['subitem'][3]['#'], 'Foo(4)' | ||
assert.equal r['listtest']['item'][1]['#'], 'Qux.' | ||
assert.equal r['listtest']['item'][2]['#'], 'Quux.' | ||
test.finish() | ||
|
||
fs.readFile __dirname + '/fixtures/sample.xml', (err, data) -> | ||
x2js.parseString data |
This file was deleted.
Oops, something went wrong.