mapillary-js/spec/graph/edge/EdgeCalculator.Rotation.spec.ts
Oscar Lorentzon 8066b9c52a Use Typings instead of TSD.
Remove deprecated TSD dependency.
Use Typings to install type definitions.
Install rx typings from npm package.
2016-02-29 16:58:56 +01:00

71 lines
2.1 KiB
TypeScript

/// <reference path="../../../typings/browser.d.ts" />
import {
EdgeCalculator,
EdgeCalculatorSettings,
EdgeCalculatorDirections,
EdgeDirection,
IEdge,
IPotentialEdge
} from "../../../src/Edge";
import {Node} from "../../../src/Graph";
import {Spatial} from "../../../src/Geo";
import {EdgeCalculatorHelper} from "../../helper/EdgeCalculatorHelper.spec";
describe("EdgeCalculator.computeRotationEdges", () => {
let edgeCalculator: EdgeCalculator;
let settings: EdgeCalculatorSettings;
let directions: EdgeCalculatorDirections;
let helper: EdgeCalculatorHelper;
let spatial: Spatial;
let node: Node;
let potentialEdge: IPotentialEdge;
beforeEach(() => {
settings = new EdgeCalculatorSettings();
directions = new EdgeCalculatorDirections();
edgeCalculator = new EdgeCalculator(settings, directions);
helper = new EdgeCalculatorHelper();
spatial = new Spatial();
});
beforeEach(() => {
node = helper.createNode();
potentialEdge = helper.createPotentialEdge();
potentialEdge.distance = settings.rotationMaxDistance / 2;
});
it("should have a rotate left edge", () => {
potentialEdge.directionChange = settings.rotationMaxDirectionChange / 2;
let rotationEdges: IEdge[] = edgeCalculator.computeRotationEdges(node, [potentialEdge]);
expect(rotationEdges.length).toBe(1);
let rotationEdge: IEdge = rotationEdges[0];
expect(rotationEdge.to).toBe(potentialEdge.apiNavImIm.key);
expect(rotationEdge.data.direction).toBe(EdgeDirection.RotateLeft);
});
it("should have a rotate right edge", () => {
potentialEdge.directionChange = -settings.rotationMaxDirectionChange / 2;
let rotationEdges: IEdge[] = edgeCalculator.computeRotationEdges(node, [potentialEdge]);
expect(rotationEdges.length).toBe(1);
let rotationEdge: IEdge = rotationEdges[0];
expect(rotationEdge.to).toBe(potentialEdge.apiNavImIm.key);
expect(rotationEdge.data.direction).toBe(EdgeDirection.RotateRight);
});
});