AbstractAlgorithm
|
AbstractAlgorithm |
3 |
#constructor()
|
AbstractAlgorithm#constructor |
2 |
should be instance of AbstractAlgorithm
|
- |
|
should store parameter in "graph" field
|
- |
|
#step()
|
AlgorithmResult#step |
1 |
should return false
|
- |
|
AlgorithmResult
|
AlgorithmResult |
9 |
#constructor()
|
AlgorithmResult#constructor |
2 |
should be instance of AlgorithmResult
|
- |
|
should start with a step index of -1
|
- |
|
#stepForward()
|
AlgorithmResult#stepForward |
3 |
should step forward in the timeline
|
- |
|
should step forward from index before first step
|
- |
|
should not step past the final step
|
- |
|
#stepBackward()
|
AlgorithmResult#stepBackward |
3 |
should step backward in the timeline
|
- |
|
should step back from index past final step
|
- |
|
should not step past the initial step
|
- |
|
#addStep(step)
|
AlgorithmResult#addStep |
1 |
should add the step to timeline
|
- |
|
StepBuilder
|
StepBuilder |
9 |
#constructor()
|
StepBuilder#constructor |
1 |
should be instance of StepBuilder
|
- |
|
#newStep
|
StepBuilder#newStep |
2 |
should create a new Step object in the "step" field
|
- |
|
should store parameter as step description
|
- |
|
#addChange
|
StepBuilder#addChange |
4 |
should throw error if no Step has been created yet
|
- |
|
should add change with nodeFields if given a Node
|
- |
|
should add change with edgeFields if given an Edge
|
- |
|
should throw error if object is not a Node or Edge
|
- |
|
#completeStep
|
StepBuilder#completeStep |
2 |
should add the step to the algorithm results
|
- |
|
should set the "step" field to null
|
- |
|
Step
|
Step |
7 |
#constructor()
|
Step#constructor |
3 |
should be instance of Step
|
- |
|
should store the parameter in "description" field
|
- |
|
should have default description
|
- |
|
#addChange()
|
Step#addChange |
1 |
should add change object to "changes" field
|
- |
|
#applyPre
|
Step#applyPre |
1 |
should apply the "pre" step values for all change objects
|
- |
|
#applyDuring
|
Step#applyDuring |
1 |
should apply the "during" step values for all change objects
|
- |
|
#applyPost
|
Step#applyPost |
1 |
should apply the "post" step values for all change objects
|
- |
|
TraversalAlgorithm
|
- |
24 |
#constructor()
|
- |
1 |
should create instance of TraversalAlgorithm
|
- |
|
#inputs
|
- |
2 |
should contain field named "source"
|
- |
|
should require "source" to be a Node
|
- |
|
#visitNode()
|
- |
4 |
should mark node as visited in graphState
|
- |
|
should add adjacent edge to queue
|
- |
|
should add self-loop edges to queue
|
- |
|
should not add visited edges to queue
|
- |
|
#visitEdge()
|
- |
5 |
should mark edge as visited in graphState
|
- |
|
should add startNode to queue if unvisited and edge is not directed
|
- |
|
should add only destNode to queue if unvisited and edge is directed
|
- |
|
should not add visited nodes to queue
|
- |
|
should handle self-loop edges
|
- |
|
#hasVisited()
|
- |
4 |
should return false if node has not been visited
|
- |
|
should return false if edge has not been visited
|
- |
|
should return true for node after calling visitNode on that node
|
- |
|
should return true for edge after calling visitEdge on that edge
|
- |
|
#step()
|
- |
8 |
should throw error if next item is not Node or Edge
|
- |
|
should start from #source field object
|
- |
|
should not mark algorithm as complete if it hasn't started yet
|
- |
|
should mark algorithm as complete if queue is empty
|
- |
|
should return false if complete
|
- |
|
should return true if not complete
|
- |
|
should call visitNode if next item is a node
|
- |
|
should call visitEdge if next item is an edge
|
- |
|
SolidEdge
|
- |
1 |
#constructor
|
- |
1 |
should create instance of SolidEdge
|
- |
|
Graph
|
- |
21 |
#constructor(x, y)
|
- |
2 |
should accept iterable arguments
|
- |
|
should work with no arguments
|
- |
|
#addNode(node)
|
- |
2 |
should add to nodes
|
- |
|
should not add duplicate node
|
- |
|
#removeNode(node)
|
- |
3 |
should remove from nodes
|
- |
|
should remove from nodes and edges
|
- |
|
should not remove bogus node
|
- |
|
#addEdge(edge)
|
- |
3 |
should throw error when edge nodes are not in graph
|
- |
|
should add to edges
|
- |
|
should not add duplicate edge
|
- |
|
#removeEdge(edge)
|
- |
1 |
should remove from edges
|
- |
|
#hasEdge(start, dest)
|
- |
3 |
should throw error if nodes are not in graph
|
- |
|
should return true if has edge
|
- |
|
should not add duplicate edge
|
- |
|
#hasComponent(x, y, ignore)
|
- |
1 |
should return false for empty graph
|
- |
|
#getComponent(x, y)
|
- |
2 |
should return null for empty graph
|
- |
|
should return non-null when clicking on a node
|
- |
|
#isNodeCollision(testNode, x, y)
|
- |
2 |
should return true if within 60
|
- |
|
should return false if farther than 60
|
- |
|
#forEachNode(callback)
|
- |
2 |
should run callback(node) for each node
|
- |
|
should break if callback(node) returns false
|
- |
|
CircleNode
|
- |
9 |
#constructor
|
- |
1 |
should create instance of CircleNode
|
- |
|
#containsPoint
|
- |
2 |
should contain this point
|
- |
|
should not contain this point
|
- |
|
#distanceToPoint
|
- |
3 |
should do this distance calculation
|
- |
|
should do this simple distance calculation 2
|
- |
|
should do this negative point test
|
- |
|
#edgePointInDirection
|
- |
3 |
should do this simple point check
|
- |
|
should account for a point within the radius of the node
|
- |
|
should throw error when point is at node origin
|
- |
|
Queue
|
- |
23 |
#constructor
|
- |
1 |
creates instance of Queue
|
- |
|
#size
|
- |
3 |
should be 0 for empty queue
|
- |
|
should increment for each enqueue
|
- |
|
should decrement for each dequeue
|
- |
|
#clear
|
- |
1 |
should clear the queue
|
- |
|
#enqueue
|
- |
4 |
should add item to queue
|
- |
|
should add item to back of queue
|
- |
|
should throw error when adding null
|
- |
|
should throw error when adding undefined
|
- |
|
#dequeue
|
- |
4 |
should return null for empty queue
|
- |
|
should return the first item in queue
|
- |
|
should remove the first item in queue
|
- |
|
should handle offset when more than half empty
|
- |
|
#peek
|
- |
3 |
should return null for empty queue
|
- |
|
should return the first item in queue
|
- |
|
should not remove item from queue
|
- |
|
#has
|
- |
4 |
should throw error when checking null
|
- |
|
should throw error when checking undefined
|
- |
|
should return true if item is in queue
|
- |
|
should return false if item is not in queue
|
- |
|
#forEach
|
- |
3 |
should iterate through all items
|
- |
|
should stop if callback returns false
|
- |
|
should iterate in order starting from the front of the queue
|
- |
|
Serializer
|
- |
7 |
#constructor
|
- |
1 |
creates instance of Serializer
|
- |
|
#emptyGraph
|
- |
3 |
should create valid graph obj export
|
- |
|
should create valid graph obj import
|
- |
|
should fail cleanly on importing malformed input
|
- |
|
#populatedGraph
|
- |
3 |
should create valid graph obj export
|
- |
|
should create valid graph obj import
|
- |
|
should create valid graph obj import
|
- |
|
Stack
|
- |
22 |
#constructor
|
- |
1 |
creates instance of Stack
|
- |
|
#size
|
- |
3 |
should be 0 for empty stack
|
- |
|
should increment for each push
|
- |
|
should decrement for each pop
|
- |
|
#clear
|
- |
1 |
should clear the stack
|
- |
|
#push
|
- |
4 |
should add item to stack
|
- |
|
should add item to top of stack
|
- |
|
should throw error when adding null
|
- |
|
should throw error when adding undefined
|
- |
|
#pop
|
- |
3 |
should return null for empty stack
|
- |
|
should return the item on top of stack
|
- |
|
should remove the top item in stack
|
- |
|
#peek
|
- |
3 |
should return null for empty stack
|
- |
|
should return the item on top of stack
|
- |
|
should not remove item from stack
|
- |
|
#has
|
- |
4 |
should throw error when checking null
|
- |
|
should throw error when checking undefined
|
- |
|
should return true if item is in stack
|
- |
|
should return false if item is not in stack
|
- |
|
#forEach
|
- |
3 |
should iterate through all items
|
- |
|
should stop if callback returns false
|
- |
|
should iterate in order starting from the top of the stack
|
- |
|
EdgeTool
|
- |
9 |
#constructor
|
- |
1 |
should create instance of EdgeTool
|
- |
|
#hasModes
|
- |
1 |
should return true
|
- |
|
#selectObject
|
- |
4 |
should not select edges
|
- |
|
should store node in "start"
|
- |
|
should add edge if "start" node exists
|
- |
|
should reset fields after adding edge
|
- |
|
#selectNone
|
- |
2 |
should do nothing if no node is selected
|
- |
|
should deselect nodes if selected
|
- |
|
#cancel
|
- |
1 |
should cancel action by clearing fields
|
- |
|
EraseTool
|
- |
11 |
#constructor
|
- |
1 |
should create instance of EraseTool
|
- |
|
#preSelectObject
|
- |
1 |
should return true
|
- |
|
#preDragObject
|
- |
1 |
should return false
|
- |
|
#selectObject
|
- |
4 |
should remove nodes
|
- |
|
should remove nodes and the edges connected to that node
|
- |
|
should remove edges
|
- |
|
should not handle other types of objects
|
- |
|
#dragOverObject
|
- |
4 |
should remove nodes
|
- |
|
should remove nodes and the edges connected to that node
|
- |
|
should remove edges
|
- |
|
should not handle other types of objects
|
- |
|
MoveTool
|
- |
9 |
#constructor
|
- |
1 |
should create instance of MoveTool
|
- |
|
#dragObject
|
- |
2 |
should move node
|
- |
|
should not move edge
|
- |
|
#dropOnObject
|
- |
4 |
should not allow dropping on other nodes
|
- |
|
should move dragged node back to original position on drop failure
|
- |
|
should ignore collision with edges
|
- |
|
should not allow dropping non-node objects
|
- |
|
#dropOnNone
|
- |
2 |
should not allow collision with node
|
- |
|
should ignore collision with edges
|
- |
|
NodeTool
|
- |
8 |
#constructor
|
- |
1 |
should create instance of NodeTool
|
- |
|
#hasModes
|
- |
1 |
should return true
|
- |
|
#selectObject
|
- |
2 |
should not add a node on another node
|
- |
|
should add node if object is an edge
|
- |
|
#selectNone
|
- |
2 |
should add node if no collisions detected
|
- |
|
should not add node if colliding with another node
|
- |
|
#dropOnNone
|
- |
2 |
should add node if no collisions detected
|
- |
|
should not add node if colliding with another node
|
- |
|
Tool
|
- |
7 |
#constructor
|
- |
1 |
should create instance of Tool
|
- |
|
#hasModes
|
- |
1 |
should return false
|
- |
|
#hasInputs
|
- |
1 |
should return false
|
- |
|
#preSelectObject
|
- |
1 |
should return true
|
- |
|
#preDragObject
|
- |
1 |
should return true
|
- |
|
test/tool/tool-test.js |
- |
2 |
should be a function
|
- |
|
should be callable
|
- |
|
Line2D
|
Line2D |
6 |
#constructor(a, b)
|
Line2D#constructor |
1 |
creates instance of Line2D
|
- |
|
#hasPoint(c)
|
Line2D#hasPoint |
5 |
should return true if point is between a and b
|
- |
|
should return true if point is on the line but not between a and b
|
- |
|
should return true if point has same coordinates as a
|
- |
|
should return true if point has same coordinates as b
|
- |
|
should return false if point is not on the line
|
- |
|
Point2D
|
Point2D |
22 |
#constructor(x, y)
|
Point2D#constructor |
2 |
creates instance of Point2D
|
- |
|
should set values below the defined epsilon to zero
|
- |
|
#equals(point)
|
Point2D#equals |
4 |
should return true if the same point object is passed in
|
- |
|
should return true if coordinates are equal
|
- |
|
should return false if x-coordinates are not equal
|
- |
|
should return false if y-coordinates are not equal
|
- |
|
#distanceTo(point)
|
Point2D#distanceTo |
2 |
should return the Euclidian distance (i.e. straight line distance)
|
- |
|
should return zero if distance less than the defined epsilon
|
- |
|
#relativePositionToTriangle2D(oldTriangle, newTriangle)
|
Point2D#relativePositionToTriangle2D |
7 |
should not change the coordinates of the original point
|
- |
|
should return vertex A on new triangle if on vertex A of old triangle
|
- |
|
should return vertex B on new triangle if on vertex B of old triangle
|
- |
|
should return vertex C on new triangle if on vertex C of old triangle
|
- |
|
should return the centroid of new triangle if on centroid of old triangle
|
- |
|
should return point on side of new triangle if on side of old triangle
|
- |
|
should be able to handle triangle vertex order rotations
|
- |
|
#translateVec(vec)
|
Point2D#translateVec |
2 |
should be translated in the vector direction
|
- |
|
should not modify values of the original point object
|
- |
|
#lineTo(point)
|
Point2D#lineTo |
3 |
should create line with current point as first point
|
- |
|
should create line with other point as second point
|
- |
|
should create line using references to the original point objects
|
- |
|
#vectorTo(point)
|
Point2D#vectorTo |
2 |
should create vector from first point to second point
|
- |
|
should be able to return vectors with negative components
|
- |
|
Triangle2D
|
Triangle2D |
5 |
#constructor(a, b, c)
|
Triangle2D#constructor |
1 |
creates instance of Triangle2D
|
- |
|
.area
|
Triangle2D#area |
2 |
should return the area of the triangle
|
- |
|
should return a negative value if vertexes are oriented clockwise around triangle
|
- |
|
#getBarycentricCoordinates
|
Triangle2D#getBarycentricCoordinates |
1 |
should return (1/3, 1/3) for centroid
|
- |
|
#getPointFromBarycentricCoordinates
|
Triangle2D#getPointFromBarycentricCoordinates |
1 |
should return centroid for coordinates (1/3, 1/3)
|
- |
|
Vector2D
|
Vector2D |
35 |
#constructor(a, b)
|
Vector2D#constructor |
1 |
creates instance of Vector2D
|
- |
|
.length
|
Vector2D#length |
1 |
should return the magnitude of the vector
|
- |
|
#equals(vec)
|
Vector2D#equals |
4 |
should return true if the same vector object is passed in
|
- |
|
should return true if the x- and y-components are equal
|
- |
|
should return false if the x-components are not equal
|
- |
|
should return false if the y-components are not equal
|
- |
|
#add(vec)
|
Vector2D#add |
3 |
should add the x- and y-components
|
- |
|
should work with negative x- and y- components
|
- |
|
should not modify original vectors
|
- |
|
#sub(vec)
|
Vector2D#sub |
3 |
should add the x- and y-components
|
- |
|
should work with negative x- and y- components
|
- |
|
should not modify original vectors
|
- |
|
#dot(vec)
|
Vector2D#dot |
5 |
should find the dot product between two vectors
|
- |
|
should be zero if the vectors are orthogonal
|
- |
|
should be equal to product of magnitudes if the vectors are in the same direction
|
- |
|
should be equal to negative product of magnitudes if the vectors are in the opposite direction
|
- |
|
should not modify original vectors
|
- |
|
#cross(vec)
|
Vector2D#cross |
4 |
should return the "cross product" of the two vectors
|
- |
|
should return zero if the vectors are parallel
|
- |
|
should return zero if the vectors have zero length
|
- |
|
should not modify original vectors
|
- |
|
#scale(n)
|
Vector2D#scale |
4 |
should scale vector by the number
|
- |
|
should scale vector by fractions
|
- |
|
should scale vector by negative numbers
|
- |
|
should not modify original vector
|
- |
|
#rotateDegrees(deg)
|
Vector2D#rotateDegrees |
2 |
should rotate vector by the given number of degrees
|
- |
|
should not modify original vector
|
- |
|
#rotateRadians(rad)
|
Vector2D#rotateRadians |
2 |
should rotate vector by the given number of radians
|
- |
|
should not modify original vector
|
- |
|
#degreesTo(vec)
|
Vector2D#degreesTo |
4 |
should return the degrees between the vectors
|
- |
|
should not return a negative value
|
- |
|
should handle floating point precision errors
|
- |
|
should return zero if vectors are in same direction
|
- |
|
#projectOnto(vec)
|
Vector2D#projectOnto |
2 |
should return a projection of the current vector onto the given vector
|
- |
|
should not modify original vectors
|
- |
|