D3: Choropleth Map project Test #9

Did anybody else have a problem with the legend from the D3: Cloropeth Map project?
For some reasons I can’t figure out why the testing won’t accept that my map legend already has more than 4 colors.

The output is literally just this:
(“There should be at least four fill colors used for the legend : expected false to be true”)

I already changed from a d3 scalesequential legend to the one that I used in the previous project where the legend test worked just fine.

Anyhow, here is the codepen: https://codepen.io/lars281/full/JjPeMyO

Any ideas would be highly appreciated!

EDIT:
I managed to fix the problem.

This is the test to be passed:

var e=document.querySelectorAll("#legend rect");o.assert.isTrue(te(e,4),"There should be at least four fill colors used for the legend ")

Turns out my legend consisted of several rect elements all with a different color each and each of them with an id of “legend”. For the test to pass though you need to have one single element with an id of “legend” and inside of that element you need to have more than 4 rect elements with different fill attributes.

I hope that made sense.

1 Like