Skip to content

Commit cd62c61

Browse files
savvinsergeyignatvilesov
authored andcommitted
Added unit test for features from 1.3.0 version (#27)
1 parent 2118be8 commit cd62c61

File tree

2 files changed

+118
-5
lines changed

2 files changed

+118
-5
lines changed

test/visualBuilder.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,38 @@ module powerbi.extensibility.visual.test {
5454
}
5555

5656
public get axis() {
57-
return this.mainElement.children("g.axis");
57+
return this.mainElement
58+
.children("g.axis");
5859
}
5960

6061
public get axisTicks() {
61-
return this.axis.children("g.tick");
62+
return this.axis
63+
.children("g.tick");
64+
}
65+
66+
public get axisTicksLine() {
67+
return this.axisTicks
68+
.children("line");
69+
}
70+
71+
public get axisTicksText() {
72+
return this.axisTicks
73+
.children("text");
6274
}
6375

6476
public get chart() {
65-
return this.mainElement.children("g.chart");
77+
return this.mainElement
78+
.children("g.chart");
79+
}
80+
81+
public get chartLine() {
82+
return this.chart
83+
.children("line.chart-line");
84+
}
85+
86+
public get taskRect() {
87+
return this.tasks
88+
.children("rect.task-lines");
6689
}
6790

6891
public get taskLabels() {
@@ -78,11 +101,13 @@ module powerbi.extensibility.visual.test {
78101
}
79102

80103
public get tasks() {
81-
return this.tasksGroups.children("g.task");
104+
return this.tasksGroups
105+
.children("g.task");
82106
}
83107

84108
public get taskResources() {
85-
return this.tasks.children("text.task-resource");
109+
return this.tasks
110+
.children("text.task-resource");
86111
}
87112

88113
public get taskProgress() {

test/visualTest.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,46 @@ module powerbi.extensibility.visual.test {
462462
});
463463
});
464464

465+
describe("Task Settings", () => {
466+
it("color", (done) => {
467+
dataView = defaultDataViewBuilder.getDataView([
468+
GanttData.ColumnTask,
469+
GanttData.ColumnStartDate,
470+
GanttData.ColumnDuration,
471+
GanttData.ColumnResource]);
472+
473+
let color: string = GanttBuilder.getRandomHexColor();
474+
dataView.metadata.objects = {
475+
taskConfig: {
476+
fill: GanttBuilder.getSolidColorStructuralObject(color)
477+
}
478+
};
479+
480+
visualBuilder.updateRenderTimeout(dataView, () => {
481+
visualBuilder.taskRect.toArray().map($).forEach(e =>
482+
assertColorsMatch(e.css("fill"), color));
483+
484+
done();
485+
});
486+
});
487+
488+
it("height", (done) => {
489+
let height: number = 50;
490+
dataView.metadata.objects = {
491+
taskConfig: {
492+
height
493+
}
494+
};
495+
496+
visualBuilder.updateRenderTimeout(dataView, () => {
497+
visualBuilder.taskRect.toArray().map($).forEach(e =>
498+
expect(+e.attr("height")).toEqual(height));
499+
500+
done();
501+
});
502+
});
503+
});
504+
465505
describe("Category Labels", () => {
466506
beforeEach(() => {
467507
dataView.metadata.objects = {
@@ -554,6 +594,54 @@ module powerbi.extensibility.visual.test {
554594
});
555595
});
556596
});
597+
598+
describe("Gantt date types", () => {
599+
it("Today color", (done) => {
600+
let color: string = GanttBuilder.getRandomHexColor();
601+
dataView.metadata.objects = {
602+
dateType: {
603+
todayColor: GanttBuilder.getSolidColorStructuralObject(color)
604+
}
605+
};
606+
607+
checkColor(visualBuilder.chartLine, color, "stroke", done);
608+
});
609+
610+
it("Axis color", (done) => {
611+
let color: string = GanttBuilder.getRandomHexColor();
612+
dataView.metadata.objects = {
613+
dateType: {
614+
axisColor: GanttBuilder.getSolidColorStructuralObject(color)
615+
}
616+
};
617+
618+
checkColor(visualBuilder.axisTicksLine, color, "stroke", done);
619+
});
620+
621+
it("Axis taxt color", (done) => {
622+
let color: string = GanttBuilder.getRandomHexColor();
623+
dataView.metadata.objects = {
624+
dateType: {
625+
axisTextColor: GanttBuilder.getSolidColorStructuralObject(color)
626+
}
627+
};
628+
629+
checkColor(visualBuilder.axisTicksText, color, "fill", done);
630+
});
631+
632+
function checkColor(
633+
elements: Element[],
634+
color: string,
635+
cssStyle: string,
636+
done: () => void): void {
637+
visualBuilder.updateRenderTimeout(dataView, () => {
638+
elements.toArray().map($).forEach(e =>
639+
assertColorsMatch(e.css(cssStyle), color));
640+
641+
done();
642+
});
643+
}
644+
});
557645
});
558646

559647
describe("View Model tests", () => {

0 commit comments

Comments
 (0)