| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- // --------------------------------------------------------------------------------------------------------------------
- //
- // basics.js - tests for node-data2xml
- //
- // Copyright (c) 2011 Andrew Chilton - http://chilts.org/
- // Written by Andrew Chilton <andychilton@gmail.com>
- //
- // License: http://opensource.org/licenses/MIT
- //
- // --------------------------------------------------------------------------------------------------------------------
- var test = require('tape');
- var data2xml = require('../data2xml');
- // --------------------------------------------------------------------------------------------------------------------
- test('some simple entities', function (t) {
- var test1 = data2xml.entitify('<hello>');
- 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 = '<tagme>';
- t.equal(test1, exp1, 'simple start tag');
- var test2 = data2xml.makeEndTag('tagme');
- var exp2 = '</tagme>';
- t.equal(test2, exp2, 'simple end tag');
- var test3 = data2xml.makeStartTag('tagme', { attr : 'value' });
- var exp3 = '<tagme attr="value">';
- t.equal(test3, exp3, '1) complex start tag');
- var test4 = data2xml.makeStartTag('tagme', { attr : '<anothertag>' });
- var exp4 = '<tagme attr="<anothertag>">';
- t.equal(test4, exp4, '2) complex start tag');
- var test5 = data2xml.makeStartTag('tagme', { attr1 : '<anothertag>', attr2 : 'val2' });
- var exp5 = '<tagme attr1="<anothertag>" attr2="val2">';
- t.equal(test5, exp5, '3) complex start tag');
- t.end();
- });
- // --------------------------------------------------------------------------------------------------------------------
|