(groupHolder, N, xAxisTicks)
| 198 | }); |
| 199 | |
| 200 | function itShouldBehaveLikeARowChartWithGroup (groupHolder, N, xAxisTicks) { |
| 201 | describe(`for ${groupHolder.groupType} data`, () => { |
| 202 | beforeEach(() => { |
| 203 | chart.group(groupHolder.group); |
| 204 | }); |
| 205 | |
| 206 | describe('rendering the row chart', () => { |
| 207 | beforeEach(() => { |
| 208 | chart.render(); |
| 209 | }); |
| 210 | |
| 211 | it('should create a root svg node', () => { |
| 212 | expect(chart.select('svg').size()).toBe(1); |
| 213 | }); |
| 214 | |
| 215 | it('should create a row group for each datum', () => { |
| 216 | expect(chart.selectAll('svg g g.row').size()).toBe(N); |
| 217 | }); |
| 218 | |
| 219 | it('should number each row sequentially with classes', () => { |
| 220 | chart.selectAll('svg g g.row').each(function (r, i) { |
| 221 | expect(d3.select(this).attr('class')).toBe(`row _${i}`); |
| 222 | }); |
| 223 | }); |
| 224 | |
| 225 | it('should fill each row rect with pre-defined colors', () => { |
| 226 | for (let i = 0; i < N; i++) { |
| 227 | expect(d3.select(chart.selectAll('g.row rect').nodes()[i]).attr('fill')) |
| 228 | .toMatchColor(dc.config.defaultColors()[i]); |
| 229 | } |
| 230 | }); |
| 231 | |
| 232 | it('should create a row label from the data for each row', () => { |
| 233 | expect(chart.selectAll('svg text.row').size()).toBe(N); |
| 234 | |
| 235 | chart.selectAll('svg g text.row').call(t => { |
| 236 | expect(+t.text()).toBe(t.datum().key); |
| 237 | }); |
| 238 | }); |
| 239 | |
| 240 | describe('row label vertical position', () => { |
| 241 | let labels, rows; |
| 242 | beforeEach(() => { |
| 243 | labels = chart.selectAll('svg text.row'); |
| 244 | rows = chart.selectAll('g.row rect'); |
| 245 | }); |
| 246 | |
| 247 | function itShouldVerticallyCenterLabelWithinRow (i) { |
| 248 | it(`should place label ${i} within row ${i}`, () => { |
| 249 | const rowpos = rows.nodes()[i].getBoundingClientRect(), |
| 250 | textpos = labels.nodes()[i].getBoundingClientRect(); |
| 251 | expect((textpos.top + textpos.bottom) / 2) |
| 252 | .toBeWithinDelta((rowpos.top + rowpos.bottom) / 2, 2); |
| 253 | }); |
| 254 | } |
| 255 | for (let i = 0; i < N ; ++i) { |
| 256 | itShouldVerticallyCenterLabelWithinRow(i); |
| 257 | } |
no test coverage detected
searching dependent graphs…