Added some unit tests

This commit is contained in:
jos 2017-08-12 19:54:21 +02:00
parent bd5331a2ac
commit 1069a033e5

View File

@ -236,6 +236,17 @@ describe ('typed', function () {
assert.strictEqual(math.type.isAssignmentNode(), false);
});
it('should test whether a value is an AccessorNode', function () {
var a = new math.expression.node.SymbolNode('a');
var index = new math.expression.node.IndexNode([new math.expression.node.ConstantNode('b')]);
assert.strictEqual(math.type.isAccessorNode(new math.expression.node.AccessorNode(a, index)), true);
assert.strictEqual(math.type.isAccessorNode(new math2.expression.node.AccessorNode(a, index)), true);
assert.strictEqual(math.type.isAccessorNode({isAccessorNode: true}), false);
assert.strictEqual(math.type.isAccessorNode(2), false);
assert.strictEqual(math.type.isAccessorNode(), false);
});
it('should test whether a value is a BlockNode', function () {
assert.strictEqual(math.type.isBlockNode(new math.expression.node.BlockNode([])), true);
assert.strictEqual(math.type.isBlockNode(new math2.expression.node.BlockNode([])), true);
@ -244,6 +255,14 @@ describe ('typed', function () {
assert.strictEqual(math.type.isBlockNode(), false);
});
it('should test whether a value is a ObjectNode', function () {
assert.strictEqual(math.type.isObjectNode(new math.expression.node.ObjectNode({})), true);
assert.strictEqual(math.type.isObjectNode(new math2.expression.node.ObjectNode({})), true);
assert.strictEqual(math.type.isObjectNode({isObjectNode: true}), false);
assert.strictEqual(math.type.isObjectNode(2), false);
assert.strictEqual(math.type.isObjectNode(), false);
});
it('should test whether a value is a ConditionalNode', function () {
var c = new math.expression.node.SymbolNode('');
var t = new math.expression.node.ConstantNode(1);