From 9a12b6025b3f91c1876b8a6eb4ef9f1434b6c12a Mon Sep 17 00:00:00 2001 From: Mark Sta Ana Date: Wed, 16 Jul 2014 17:49:45 +0100 Subject: [PATCH] Looks like website needs GetCostPath Also set global variable in browserify to constructor --- lib/fromatobree.js | 3 ++- tests/north.js | 32 ++++++++++++++++++++++++++++++++ utils/build.js | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/fromatobree.js b/lib/fromatobree.js index a826b2b..91dc3ab 100644 --- a/lib/fromatobree.js +++ b/lib/fromatobree.js @@ -181,6 +181,7 @@ FATB.prototype.GetPlace = function(place) { return found; }; +FATB.prototype.GetPathCostObject = GetPathCostObject; FATB.prototype.GetTotalCost = function(path) { var route = GetPathCostObject(path); @@ -199,7 +200,7 @@ FATB.prototype.GetTotalCost = function(path) { }; FATB.prototype.GetTotalTime = function(path) { - var route = GetPathCostObject(path); + var route = GetPathCostObject(path); //should we still do this? var time = 0; for (var place in route ) { diff --git a/tests/north.js b/tests/north.js index d1eb1ea..b5f6191 100644 --- a/tests/north.js +++ b/tests/north.js @@ -4,6 +4,38 @@ var test = require('tape').test; var FATB = require('../lib/fromatobree'); // for cost and time testing + +test("Get metadata object for path", function(t) { + var start = "Needlehole"; + var finish = "Ost Guruth"; + var fatb = new FATB({weighting:true, level:10}); + var route = fatb.FindPath(start, finish); + var metadata = fatb.GetPathCostObject(route); + var expected = { + Hobbiton : { c: 1, t: 166 } + ,Needlehole : {} + ,'West Bree' : { c: 5, t: 337 } + ,'South Bree' : { mt: 75, s: 1, st: 18 } + ,'The Forsaken Inn' : { c: 5, t: 190 } + ,'Ost Guruth' : { c:15, t: 203 } + }; + t.deepEquals(metadata, expected, "Should return a path cost object based on not meeting reqs"); + + fatb = new FATB({weighting:true, level:15}); + route = fatb.FindPath(start, finish); + metadata = fatb.GetPathCostObject(route); + expected = { + Hobbiton : { c: 1, t: 166 } + ,Needlehole : {} + ,'West Bree' : { c: 5, t: 337 } + ,'South Bree' : { mt: 75, s: 1, st: 18 } + ,'Ost Guruth' : { l:15, s: 20, st: 24 } + }; + t.deepEquals(metadata, expected, "Should return a path cost object based on meeting reqs"); + + t.end(); + +}); test("Level requirement test", function(t) { var start = "Needlehole"; var finish = "Ost Guruth"; diff --git a/utils/build.js b/utils/build.js index 39618f0..3e0363c 100755 --- a/utils/build.js +++ b/utils/build.js @@ -6,7 +6,7 @@ var uglifyjs = require('uglify-js'); var browserify = require('browserify'); function bundle(file, callback) { - var opts = { standalone: 'fatb' }; + var opts = { standalone: 'FATB' }; browserify(file).bundle(opts, callback); }