Skip to content

Commit

Permalink
FLOE-437: remove now-unneeded filterByDataId function
Browse files Browse the repository at this point in the history
  • Loading branch information
waharnum committed Feb 8, 2016
1 parent 37cdcda commit 662e782
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 44 deletions.
12 changes: 0 additions & 12 deletions src/js/d3Utils.js
Expand Up @@ -32,18 +32,6 @@ https://raw.githubusercontent.com/fluid-project/chartAuthoring/master/LICENSE.tx
return fluid.get(d, "id") || fluid.get(d, "data.id");
};

// Given a selection of D3 elements and an ID, returns only the elements
// matching that ID
floe.d3.filterByDataId = function (d3Selection, idToFilter, invertResult) {
var shouldInvert = invertResult === undefined ? false : invertResult;
return d3Selection.filter(
function (d) {
var id = floe.d3.idExtractor(d);
return shouldInvert ? id !== idToFilter : id === idToFilter;
}
);
};

floe.d3.addD3Listeners = function (jQueryElem, eventName, listener, that) {
var d3Elem = floe.d3.jQueryToD3(jQueryElem);
d3Elem.on(eventName, function (data, i) {
Expand Down
8 changes: 8 additions & 0 deletions src/js/d3ViewComponent.js
Expand Up @@ -48,6 +48,14 @@ https://raw.githubusercontent.com/fluid-project/chartAuthoring/master/LICENSE.tx
removeElementIdFromDataKey: {
funcName: "floe.d3ViewComponent.removeElementIdFromDataKey",
args: ["{arguments}.0", "{arguments}.1", "{that}"]
},
getElementsByDataKey: {
funcName: "floe.d3ViewComponent.getElementsByDataKey",
args: ["{arguments}.0", "{that}"]
},
getElementsNotMatchingDataKey: {
funcName: "floe.d3ViewComponent.getElementsNotMatchingDataKey",
args: ["{arguments}.0", "{that}"]
}

}
Expand Down
21 changes: 12 additions & 9 deletions tests/js/chartAuthoringTests.js
Expand Up @@ -94,7 +94,7 @@ https://raw.githubusercontent.com/fluid-project/chartAuthoring/master/LICENSE.tx
name: "Test the chart authoring component",
tests: [{
name: "Chart Authoring Init, Changes and Button Behaviour",
expect: 63,
expect: 69,
sequence: [{
listener: "floe.tests.chartAuthoringTester.verifyInit",
args: ["{chartAuthoring}"],
Expand Down Expand Up @@ -280,18 +280,21 @@ https://raw.githubusercontent.com/fluid-project/chartAuthoring/master/LICENSE.tx
jqUnit.assertDeepEq("currentlyPlayingData is properly relayed between chartAuthoring component and sonifier subcomponent", that.chartAuthoringInterface.sonifier.model.currentlyPlayingData, that.model.currentlyPlayingData);
jqUnit.assertDeepEq("activeRowId is the id of the currently playing data in the sonifier", that.chartAuthoringInterface.sonifier.model.currentlyPlayingData.id, that.chartAuthoringInterface.pieChart.legend.model.activeRowId);
jqUnit.assertDeepEq("activeSliceId is the id of the currently playing data in the sonifier", that.chartAuthoringInterface.sonifier.model.currentlyPlayingData.id, that.chartAuthoringInterface.pieChart.pie.model.activeSliceId);
floe.tests.chartAuthoringTester.verifyPlayHighlighting(that.chartAuthoringInterface.pieChart.legend.rows, that.chartAuthoringInterface.pieChart.legend.model.activeRowId, that.chartAuthoringInterface.pieChart.legend.options.styles.highlight);
floe.tests.chartAuthoringTester.verifyPlayHighlighting(that.chartAuthoringInterface.pieChart.pie.paths, that.chartAuthoringInterface.pieChart.pie.model.activeSliceId, that.chartAuthoringInterface.pieChart.pie.options.styles.highlight);
floe.tests.chartAuthoringTester.verifyPlayHighlighting(that.chartAuthoringInterface.pieChart.legend, that.chartAuthoringInterface.pieChart.legend.model.activeRowId, that.chartAuthoringInterface.pieChart.legend.options.styles.highlight);
floe.tests.chartAuthoringTester.verifyPlayHighlighting(that.chartAuthoringInterface.pieChart.legend, that.chartAuthoringInterface.pieChart.pie.model.activeSliceId, that.chartAuthoringInterface.pieChart.pie.options.styles.highlight);
};

floe.tests.chartAuthoringTester.verifyPlayHighlighting = function (d3Selector, currentlyPlayingDataId, highlightClass) {
var activeElement = floe.d3.filterByDataId(d3Selector, currentlyPlayingDataId);
var activeElementClasses = activeElement.attr("class");
floe.tests.chartAuthoringTester.verifyPlayHighlighting = function (d3ViewComponent, currentlyPlayingDataId, highlightClass) {

var activeElements = d3ViewComponent.getElementsByDataKey(currentlyPlayingDataId);
var activeElementClasses = activeElements.attr("class");
jqUnit.assertTrue("Active element contains the highlight class", activeElementClasses.indexOf(highlightClass) > -1);

var inactiveElements = floe.d3.filterByDataId(d3Selector, currentlyPlayingDataId, true);
var inActiveElementClasses = inactiveElements.attr("class");
jqUnit.assertFalse("Inactive elements do not contain the highlight class", inActiveElementClasses.indexOf(highlightClass) > -1);
var inactiveElements = d3ViewComponent.getElementsNotMatchingDataKey(currentlyPlayingDataId);
fluid.each(inactiveElements, function (currentElem) {
var elemClass = $(currentElem).attr("class");
jqUnit.assertFalse("Inactive elements do not contain the highlight class", elemClass.indexOf(highlightClass) > -1);
});
};

$(document).ready(function () {
Expand Down
23 changes: 0 additions & 23 deletions tests/js/d3UtilsTests.js
Expand Up @@ -95,29 +95,6 @@ https://raw.githubusercontent.com/fluid-project/chartAuthoring/master/LICENSE.tx

});

jqUnit.test("Test floe.d3.filterByDataId", function () {
jqUnit.expect(5);
var dataSet = [
{value: 100, id: "id1"},
{value: 200, id: "id2"},
{value: 300, id: "id3"}
];
var testRows = d3.select(".floc-filterByIdTable").selectAll(".floc-testRow");

testRows.data(dataSet);

var filteredRow = floe.d3.filterByDataId(testRows, "id1");

jqUnit.assertEquals("Filtered row has expected length", 1, filteredRow[0].length);
jqUnit.assertEquals("Filtered row's first item has expected ID", "id1", filteredRow[0][0].__data__.id);

var inverseFilteredRow = floe.d3.filterByDataId(testRows, "id1", true);

jqUnit.assertEquals("Inverse filtered row has expected length", 2, inverseFilteredRow[0].length);
jqUnit.assertEquals("Inverse filtered row's first item has expected ID", "id2", inverseFilteredRow[0][0].__data__.id);
jqUnit.assertEquals("Inverse filtered row's second item has expected ID", "id3", inverseFilteredRow[0][1].__data__.id);
});

// jqUnit.test("Test floe.d3ViewComponent.toggleCSSClassByDataId", function () {
// var testToggleClass = "floc-testToggleClass";
// jqUnit.expect(3);
Expand Down

0 comments on commit 662e782

Please sign in to comment.