Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add test for using NS functions (startElementNS, writeElementNS, star…

…tAtributesNS and writeAttributeNS)
  • Loading branch information...
commit 100771203fc312913d9f035272e991a490e54a88 1 parent b7b6dc1
quintela authored
Showing with 37 additions and 0 deletions.
  1. +37 −0 test/namespaces.js
View
37 test/namespaces.js
@@ -38,3 +38,40 @@ exports['t05'] = function (test) {
test.equal(this.xw.toString(), '<?xml version="1.0"?>\n<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cd="http://www.recshop.fake/cd#"><rdf:Description rdf:about="http://www.recshop.fake/cd/Empire Burlesque"><cd:artist>Bob Dylan</cd:artist><cd:country>USA</cd:country><cd:company>Columbia</cd:company><cd:price>10.90</cd:price><cd:year>1985</cd:year></rdf:Description></rdf:RDF>');
test.done();
};
+// With NS functions
+exports['t06'] = function (test) {
+ this.xw.startElementNS('t','foo');
+ test.equal(this.xw.toString(), '<t:foo/>');
+ test.done();
+};
+
+exports['t07'] = function (test) {
+ this.xw.startElementNS('foo','tag');
+ this.xw.text('fake');
+ test.equal(this.xw.toString(), '<foo:tag>fake</foo:tag>');
+ test.done();
+};
+exports['t08'] = function (test) {
+ this.xw.startElementNS('foo','tag');
+ this.xw.writeAttributeNS('foo','att',null,'value');
+ this.xw.writeAttribute('att', 'value');
+ this.xw.text('fake');
+ this.xw.endElement();
+ test.equal(this.xw.toString(), '<foo:tag foo:att="value" att="value">fake</foo:tag>');
+ test.done();
+};
+exports['t09'] = function (test) {
+ this.xw.startDocument('1.0');
+ this.xw.startElementNS('rdf','RDF').writeAttributeNS('xmlns','rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#').writeAttributeNS('xmlns','cd', 'http://www.recshop.fake/cd#');
+ this.xw.startElementNS('rdf','Description').writeAttributeNS('rdf','about', 'http://www.recshop.fake/cd/Empire Burlesque');
+ this.xw.writeElementNS('cd','artist', null, 'Bob Dylan');
+ this.xw.writeElementNS('cd','country',null, 'USA');
+ this.xw.writeElementNS('cd','company', null, 'Columbia');
+ this.xw.writeElementNS('cd','price', null, '10.90');
+ this.xw.writeElementNS('cd','year', null,'1985');
+ this.xw.endElement();
+ this.xw.endElement();
+ this.xw.endDocument();
+ test.equal(this.xw.toString(), '<?xml version="1.0"?>\n<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cd="http://www.recshop.fake/cd#"><rdf:Description rdf:about="http://www.recshop.fake/cd/Empire Burlesque"><cd:artist>Bob Dylan</cd:artist><cd:country>USA</cd:country><cd:company>Columbia</cd:company><cd:price>10.90</cd:price><cd:year>1985</cd:year></rdf:Description></rdf:RDF>');
+ test.done();
+};
Please sign in to comment.
Something went wrong with that request. Please try again.