// -------------------------------------------------------------------------------------------------------------------- // // basics.js - tests for node-data2xml // // Copyright (c) 2011 Andrew Chilton - http://chilts.org/ // Written by Andrew Chilton // // License: http://opensource.org/licenses/MIT // // -------------------------------------------------------------------------------------------------------------------- var test = require('tape'); var data2xml = require('../data2xml'); // -------------------------------------------------------------------------------------------------------------------- test('some simple entities', function (t) { var test1 = data2xml.entitify(''); var exp1 = '<hello>'; t.equal(test1, exp1, 'LT and GT entitified correctly'); var test2 = data2xml.entitify('\'&\"'); var exp2 = ''&"'; t.equal(test2, exp2, 'other entities'); t.end(); }); test('making some elements', function (t) { var test1 = data2xml.makeStartTag('tagme'); var exp1 = ''; t.equal(test1, exp1, 'simple start tag'); var test2 = data2xml.makeEndTag('tagme'); var exp2 = ''; t.equal(test2, exp2, 'simple end tag'); var test3 = data2xml.makeStartTag('tagme', { attr : 'value' }); var exp3 = ''; t.equal(test3, exp3, '1) complex start tag'); var test4 = data2xml.makeStartTag('tagme', { attr : '' }); var exp4 = ''; t.equal(test4, exp4, '2) complex start tag'); var test5 = data2xml.makeStartTag('tagme', { attr1 : '', attr2 : 'val2' }); var exp5 = ''; t.equal(test5, exp5, '3) complex start tag'); t.end(); }); // --------------------------------------------------------------------------------------------------------------------