forked from schorfES/node-junitwriter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.js
More file actions
63 lines (50 loc) · 1.45 KB
/
node.js
File metadata and controls
63 lines (50 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
var
Node = require(process.cwd() + '/lib/Node')
;
exports['The Node'] = {
'should create a xml node': function(test) {
var node = new Node('foo');
test.equals(node.toString(), '<foo/>', 'The node was not the expected one');
test.done();
},
'should concat nodes': function(test) {
var
root = new Node('foo'),
child = new Node('bar', root)
;
test.equals(root.toString(), '<foo><bar/></foo>', 'The node was not the expected one');
test.equals(child.toString(), '<bar/>', 'The node was not the expected one');
test.done();
},
'should throw an error when missing name': function(test) {
test.throws(
function() {new Node();},
'A node expects a name as string',
'The errow of a missing name param wasn\'t thrown'
);
test.done();
},
'should throw an error when name is not type of string': function(test) {
test.throws(
function() {new Node(true);},
'A node expects a name as string',
'The error of an incorrect type of the nodename wasn\'t thrown'
);
test.throws(
function() {new Node(123);},
'A node expects a name as string',
'The error of an incorrect type of the nodename wasn\'t thrown'
);
test.done();
},
'should be removeable when possible': function(test) {
var
root = new Node('foo'),
child = new Node('bar', root)
;
test.throws(function() {root.destroy();});
child.destroy();
test.equals(root.toString(), '<foo/>', 'The node was not the expected one');
test.done();
}
};