From 5546961b9c40c538f272ed9308a135f6c2a11b1f Mon Sep 17 00:00:00 2001 From: Marcus Fedarko Date: Sun, 9 Jun 2019 21:20:59 -0700 Subject: [PATCH] TST: Test CSS after updateSampleDroppedDiv() #92 --- qurro/tests/web_tests/tests/test_dom_utils.js | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/qurro/tests/web_tests/tests/test_dom_utils.js b/qurro/tests/web_tests/tests/test_dom_utils.js index e229ea79..5bdb5518 100644 --- a/qurro/tests/web_tests/tests/test_dom_utils.js +++ b/qurro/tests/web_tests/tests/test_dom_utils.js @@ -268,51 +268,75 @@ define(["dom_utils", "mocha", "chai"], function(dom_utils, mocha, chai) { }); describe("Updating the other sample-dropped divs", function() { it('Works properly for the x-axis "reason"', function() { + var divID = "xAxisSamplesDroppedDiv"; dom_utils.updateSampleDroppedDiv( [1, 2, 3, 4, 5], 15, - "xAxisSamplesDroppedDiv", + divID, "xAxis", "fieldName" ); chai.assert.equal( - document.getElementById("xAxisSamplesDroppedDiv") - .innerHTML, + document.getElementById(divID).innerHTML, "x-axis: 5 / 15 samples (33.33%) " + "can't be shown due to having an invalid " + "fieldName field." ); + chai.assert.isFalse( + document + .getElementById(divID) + .classList.contains("invisible") + ); }); it('Works properly for the color "reason"', function() { + var divID = "colorSamplesDroppedDiv"; dom_utils.updateSampleDroppedDiv( [1, 2], 7, - "colorSamplesDroppedDiv", + divID, "color", "fieldNameC" ); chai.assert.equal( - document.getElementById("colorSamplesDroppedDiv") - .innerHTML, + document.getElementById(divID).innerHTML, "Color: 2 / 7 samples (28.57%) " + "can't be shown due to having an invalid " + "fieldNameC field." ); + chai.assert.isFalse( + document + .getElementById(divID) + .classList.contains("invisible") + ); }); it('Works properly for the balance "reason"', function() { + var divID = "balanceSamplesDroppedDiv"; dom_utils.updateSampleDroppedDiv( [1, 2, 3, 4], 8, - "balanceSamplesDroppedDiv", + divID, "balance" ); chai.assert.equal( - document.getElementById("balanceSamplesDroppedDiv") - .innerHTML, + document.getElementById(divID).innerHTML, "4 / 8 samples (50.00%) " + "can't be shown due to having an invalid " + "(i.e. containing at least one 0) log ratio." ); + chai.assert.isFalse( + document + .getElementById(divID) + .classList.contains("invisible") + ); + }); + it("Makes the div invisible if the number of dropped samples is 0", function() { + var divID = "balanceSamplesDroppedDiv"; + dom_utils.updateSampleDroppedDiv([], 8, divID, "balance"); + chai.assert.isTrue( + document + .getElementById(divID) + .classList.contains("invisible") + ); }); it("Throws an error if totalSampleCount is 0", function() { chai.assert.throws(function() {