Skip to content

Commit

Permalink
FLOE-433: tests for special formatting (chartAuthoring test is breaki…
Browse files Browse the repository at this point in the history
…ng, need to investigate)
  • Loading branch information
waharnum committed Nov 6, 2015
1 parent 15b2a6f commit dd799c3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/html/pie-Tests.html
Expand Up @@ -31,5 +31,6 @@ <h2 id="qunit-userAgent"></h2>
<!-- Test HTML -->
<div class="floec-ca-pieChart-numberArray"></div>
<div class="floec-ca-pieChart-objectArray"></div>
<div class="floec-ca-pieChart-specialFormatting"></div>
</body>
</html>
41 changes: 41 additions & 0 deletions tests/js/pieTests.js
Expand Up @@ -208,4 +208,45 @@ https://raw.githubusercontent.com/fluid-project/chartAuthoring/master/LICENSE.tx
jqUnit.assertEquals("The total value is calculated as expected", floe.tests.chartAuthoring.objectArrayChangeInPlaceTotal, that.model.total.value);
});

floe.tests.chartAuthoring.percentageArray = [{
id: "tenPercent",
value: 20
}, {
id: "fiftyPercent",
value: 100
}, {
id: "fortyPercent",
value: 80
}];

floe.tests.chartAuthoring.expectedTenPercentDisplayValue = "20/200 (10.00%)";
floe.tests.chartAuthoring.expectedFiftyPercentDisplayValue = "100/200 (50.00%)";
floe.tests.chartAuthoring.expectedFortyPercentDisplayValue = "80/200 (40.00%)";

jqUnit.test("Test the functions for custom formatting of data values in pie slices", function () {
jqUnit.expect(3);

var that = floe.tests.chartAuthoring.pieChart.pie(".floec-ca-pieChart-specialFormatting", {
model: {
dataSet: floe.tests.chartAuthoring.percentageArray
},
pieOptions: {
sliceTextDisplayTemplate: "%value/%total (%percentage%)",
width: "400",
height: "400"
}
});

var customDisplayValues = [floe.tests.chartAuthoring.expectedTenPercentDisplayValue, floe.tests.chartAuthoring.expectedFiftyPercentDisplayValue, floe.tests.chartAuthoring.expectedFortyPercentDisplayValue];

var d3Elem = floe.d3.jQueryToD3(that.locate("text"));

d3Elem.each(function (d,i) {
var displayedValue = d3.select(this).text();
jqUnit.assertEquals("Displayed values are in sync with the current model", customDisplayValues[i], displayedValue);
});


});

})(jQuery, fluid);

0 comments on commit dd799c3

Please sign in to comment.