Skip to content

Commit

Permalink
use correct sg files in unit tests
Browse files Browse the repository at this point in the history
jslib -> lib
it & test use same jasmine files
  • Loading branch information
David Korz committed Apr 19, 2014
1 parent 57db6ac commit fc71927
Show file tree
Hide file tree
Showing 199 changed files with 154 additions and 21,685 deletions.
4 changes: 2 additions & 2 deletions Building.md
Expand Up @@ -8,7 +8,7 @@ Directories

- *dashboard* - Example sparkle-graph dashboards.

- *jslib* - Javascript libraries used by sg.js (primarily: require.js, when.js, d3.js)
- *lib* - Javascript libraries used by sg.js (primarily: require.js, when.js, d3.js)

##### sg.js tests
- *test/web/spec* - unit tests (using jasmine 2)
Expand Down Expand Up @@ -60,5 +60,5 @@ integration tests (requires that cassandra is running locally)

javascript tests in e.g. chrome, browse to:

file:///Users/MyAccountNameHere/sparkle-graph/src/test/web/SpecRunner.html
file:///Users/MyAccountNameHere/sparkle-graph/src/test/web/index.html

2 changes: 1 addition & 1 deletion dashboard/db-requests/dbDashboard.js
@@ -1,4 +1,4 @@
require( ["jslib/d3", "sg/dashboard", "sg/sideAxis", "sg/palette", "sg/linePlot" ],
require( ["lib/d3", "sg/dashboard", "sg/sideAxis", "sg/palette", "sg/linePlot" ],
function(_d3, dashboard, sideAxis, palette, linePlot) {

var greyish = d3.scale.ordinal().range(["#BFB9A2"]),
Expand Down
2 changes: 1 addition & 1 deletion dashboard/db-requests/index.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="css/graph.css">
<script data-main="dbDashboard.js" src="jslib/require.js"></script>
<script data-main="dbDashboard.js" src="lib/require.js"></script>
<body>
2 changes: 1 addition & 1 deletion dashboard/simple/index.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="css/graph.css">
<script data-main="simple.js" src="jslib/require.js"></script>
<script data-main="simple.js" src="lib/require.js"></script>
<body>
2 changes: 1 addition & 1 deletion dashboard/ssl-sessions/index.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="css/graph.css">
<script data-main="sessions.js" src="jslib/require.js"></script>
<script data-main="sessions.js" src="lib/require.js"></script>
<body>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion sg/bar.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/d3", "sg/domCache"],
define(["lib/d3", "sg/domCache"],
function(_, domCache) {

return function() {
Expand Down
2 changes: 1 addition & 1 deletion sg/categorized.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/d3", "sg/scatterLine", "sg/palette", "sg/util"],
define(["lib/d3", "sg/scatterLine", "sg/palette", "sg/util"],
function(_d3, scatterLine, palette, _util) {

/** Divide a Series into categories and then plot each category with
Expand Down
2 changes: 1 addition & 1 deletion sg/chart.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/d3", "jslib/when/monitor/console", "jslib/when/when",
define(["lib/d3", "lib/when/monitor/console", "lib/when/when",
"sg/data", "sg/util", "sg/zoom", "sg/resizable", "sg/linePlot", "sg/richAxis",
"sg/legend", "sg/timeClip", "sg/domCache"],
function(_d3, _console, when, dataApi, _util, zoomBrush, resizable, linePlot, richAxis,
Expand Down
2 changes: 1 addition & 1 deletion sg/combiner.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/d3", "sg/domCache", "sg/barGroup", "sg/streamWrapper"],
define(["lib/d3", "sg/domCache", "sg/barGroup", "sg/streamWrapper"],
function(_, domCache, barGroup, streamWrap) {

var combiner = function() {
Expand Down
2 changes: 1 addition & 1 deletion sg/controlPanel.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define (["jslib/d3", "sg/util", "sg/metadata", "sg/dropDown"],
define (["lib/d3", "sg/util", "sg/metadata", "sg/dropDown"],
function(_d3, _util, networkMetaDataApi, dropDown) {

/** A dashboard control panel. More functionality to come! */
Expand Down
2 changes: 1 addition & 1 deletion sg/dashboard.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define (["jslib/when/when", "jslib/d3",
define (["lib/when/when", "lib/d3",
"sg/util", "sg/richAxis", "sg/maxLock", "sg/data",
"sg/zoom", "sg/chart", "sg/domCache"],
function(when, _d3, util, _richAxis, _maxLock, networkDataApi,
Expand Down
3 changes: 2 additions & 1 deletion sg/data.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/when/monitor/console", "sg/request"],
define(["lib/when/monitor/console", "sg/request"],
function(_console, request) {

/** Fetch data points from the server. Return a When that completes with the raw data
Expand All @@ -37,6 +37,7 @@ define(["jslib/when/monitor/console", "sg/request"],
function streamsResponse(message) {
var streamsMessage = JSON.parse(message);
return streamsMessage.message.streams[0].data;
// TODO: Handle more than one stream
}

/** Construct a StreamRequest to request a transform from the server */
Expand Down
2 changes: 1 addition & 1 deletion sg/default.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

require(["jslib/d3", "sg/serverDescribedGraph"], function (_, serverDescribedChart) {
require(["lib/d3", "sg/serverDescribedGraph"], function (_, serverDescribedChart) {

/** Create a simple xy chart. The server specifies the chart title and which data series to plot.
* This is intended to be a basic default plot of time series data, e.g. when launching the sg tool
Expand Down
2 changes: 1 addition & 1 deletion sg/domCache.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/d3"],
define(["lib/d3"],
function(_) {

/** Cache some private data in a javascript object e.g. a DOM node.
Expand Down
4 changes: 2 additions & 2 deletions sg/dropDown.js
Expand Up @@ -15,15 +15,15 @@
requirejs.config({
paths:{
'select2': 'http://ivaynberg.github.com/select2/select2-3.2/select2',
'jquery': 'jslib/jquery'
'jquery': 'lib/jquery'
},
shim: {
'select2': ['jquery']
}
});

//define(["jquery", "select2", "sg/util"], // TODO we saw some problems loading select2, temporarily disabled
define(["jslib/jquery", "sg/util"],
define(["lib/jquery", "sg/util"],
function (_jquery, _util, _select2) {

/** create a select2 based dropdown menu */
Expand Down
2 changes: 1 addition & 1 deletion sg/legend.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/d3"], function(_) {
define(["lib/d3"], function(_) {
/** Display a visual 'key' - named color swatches.
*
* Bind to LegendData
Expand Down
2 changes: 1 addition & 1 deletion sg/linePlot.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/d3"],
define(["lib/d3"],
function(_) {

/** Plot a single line into a container.
Expand Down
55 changes: 53 additions & 2 deletions sg/localData.js
Expand Up @@ -12,21 +12,35 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/when/when"], function(when) {
define(["lib/when/when"], function(when) {

/** returns an object that supports the async data() api
*
* Call with a local array of data: [Date, Number] */
return function(dataArray) {

returnFn.millisToDates = millisToDates;
returnFn.toObject = toObject;
return returnFn;

/* return data points within the domain from a local RAM array.
* (see data.js data api)
*/
return function(setName, column, params) {
function returnFn(setName, column, params) {
var domain = params.domain,
first,
extra = params.edgeExtra;

// Simulate DomainRange transform if requested
if (params.transform == "DomainRange") {
var d = minMax(dataArray, 0);
var r = minMax(dataArray, 1);

return when.resolve(
[ [["domain",d],["range",r]] ]
);
}

dataArray.every( function(datum, index) {
var dataTime = datum[0];
if (dataTime < domain[0]) {
Expand All @@ -51,6 +65,43 @@ define(["jslib/when/when"], function(when) {
var result = dataArray.slice(start, endDex + 1);
return when.resolve(result);
}

/** convert [Millis,Number] to [Date, Number] format */
function millisToDates(jsonArray) {
var data = jsonArray.map( function (row) {
var time = new Date(row[0]);
return [time, row[1]];
});
return data;
}

/** convert [String,Value] to {name1: value1, name2: value2}. */
function toObject(jsonArray) {
var result = {};
jsonArray[0].forEach( function(element) {
result[element[0]] = element[1];
});
return result;
}

/**
* Return a 2 value array of the min & max of a column from a 2D array.
* @param array An array of 2 arrays
* @param index The 'column' of the array to find the min & max for.
* @returns {*[]}
*/
function minMax(array, index) {
return [
reduce(array, Math.min, index),
reduce(array, Math.max, index)
];
}

function reduce(array, reducer, index) {
return array.reduce(function(prev, current) {
return reducer(prev, current[index]);
}, array[0][index]);
}

};
});
2 changes: 1 addition & 1 deletion sg/maxLock.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/d3", "sg/maxLock"], function(_, maxLock) {
define(["lib/d3", "sg/maxLock"], function(_, maxLock) {
/** Display a lockable maximum value indicator for a Y axis.
*
* When the lock/unlock button is clicked, a custom event 'toggleMaxLock' is fired.
Expand Down
2 changes: 1 addition & 1 deletion sg/metadata.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/when/monitor/console", "sg/request"], function(_console, request) {
define(["lib/when/monitor/console", "sg/request"], function(_console, request) {

/** Fetch list of all data sets from the server.
* Returns a When that contains an array of strings e.g. ["foo/b.csv", "bar/c.csv"] */
Expand Down
2 changes: 1 addition & 1 deletion sg/palette.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define (["jslib/d3"], function(_) {
define (["lib/d3"], function(_) {

var palette = {
category10 : d3.scale.category10,
Expand Down
2 changes: 1 addition & 1 deletion sg/request.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/when/monitor/console", "jslib/when/when", "jslib/d3"],
define(["lib/when/monitor/console", "lib/when/when", "lib/d3"],
function(_console, when, _d3) {


Expand Down
2 changes: 1 addition & 1 deletion sg/resizable.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define (["jslib/d3", "sg/util"], function(_d3, _util) {
define (["lib/d3", "sg/util"], function(_d3, _util) {

/** Make an svg box resizable by dragging on a resize widget.
*
Expand Down
2 changes: 1 addition & 1 deletion sg/richAxis.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/d3", "sg/util", "sg/maxLock"], function(_d3, _util, maxLock) {
define(["lib/d3", "sg/util", "sg/maxLock"], function(_d3, _util, maxLock) {

/** A display d3.axis with a few extensions:
* label - a code or css styled text label
Expand Down
2 changes: 1 addition & 1 deletion sg/scatterLine.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/d3", "sg/symbolMark", "sg/util"], function(_d3, symbolMark, _util) {
define(["lib/d3", "sg/symbolMark", "sg/util"], function(_d3, symbolMark, _util) {

/** Plot of scatter of marks on a horizontal line
* Bind to an array containing a single Categorized object */
Expand Down
2 changes: 1 addition & 1 deletion sg/sideAxis.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/d3", "sg/util", "sg/richAxis", "sg/palette"],
define(["lib/d3", "sg/util", "sg/richAxis", "sg/palette"],
function(_d3, _util, richAxis, palette) {

/** Attach a lockable axis to one side of the chart.
Expand Down
2 changes: 1 addition & 1 deletion sg/symbolMark.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/d3"], function(_) {
define(["lib/d3"], function(_) {

/** Return a function which plots a single d3Symbol. */
return function() {
Expand Down
2 changes: 1 addition & 1 deletion sg/timeClip.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define(["jslib/d3", "sg/domCache"], function(_d3, domCache) {
define(["lib/d3", "sg/domCache"], function(_d3, domCache) {

/** Add an svg clipping rectangle to a selection. If called within a transition, animate the
* clip rectangle to the it's new size. */
Expand Down
2 changes: 1 addition & 1 deletion sg/zoom.js
Expand Up @@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License. */

define (["jslib/d3", "sg/domCache"], function(_, domCache) {
define (["lib/d3", "sg/domCache"], function(_, domCache) {
/** Setup drag zooming.
*
* Wraps a d3.brush with a few modifications:
Expand Down
1 change: 0 additions & 1 deletion sparkle/src/it/static/index.html
@@ -1,7 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sparkle IT Jasmine Spec Runner</title>
<link rel="shortcut icon" type="image/png" href="jasmine-2.0.0/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="jasmine-2.0.0/jasmine.css">
Expand Down
1 change: 1 addition & 0 deletions sparkle/src/it/static/jasmine-2.0.0
1 change: 1 addition & 0 deletions sparkle/src/it/static/lib

0 comments on commit fc71927

Please sign in to comment.