Skip to content

Commit

Permalink
🧪 (slope) fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Nov 22, 2024
1 parent fc0655c commit 196784f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function getSeriesName({

// if columns are plotted, use the column name
// and prepend the entity name if multiple entities can be selected
return availableEntityNames.length > 1 && canSelectMultipleEntities
return availableEntityNames.length > 1 || canSelectMultipleEntities
? `${entityName} - ${columnName}`
: columnName
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,20 @@ import {
SynthesizeGDPTable,
} from "@ourworldindata/core-table"
import { ChartManager } from "../chart/ChartManager"
import { DEFAULT_SLOPE_CHART_COLOR } from "./SlopeChartConstants"
import { isNumber, OwidTableSlugs } from "@ourworldindata/utils"
import { isNumber } from "@ourworldindata/utils"

const table = SynthesizeGDPTable({ timeRange: [2000, 2010] })
const manager: ChartManager = {
table,
yColumnSlug: SampleColumnSlugs.Population,
selection: table.availableEntityNames,
startTime: 2000,
endTime: 2009,
}

it("can create a new slope chart", () => {
const chart = new SlopeChart({ manager })
expect(chart.series.length).toEqual(2)
})

it("slope charts can have different colors", () => {
const manager: ChartManager = {
table,
yColumnSlug: SampleColumnSlugs.Population,
colorColumnSlug: OwidTableSlugs.entityName,
}
const chart = new SlopeChart({ manager })
expect(chart.series[0].color).not.toEqual(DEFAULT_SLOPE_CHART_COLOR)
expect(chart.series).toEqual(2)
})

it("filters non-numeric values", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export class SlopeChart
return map
}

@computed private get series(): SlopeChartSeries[] {
@computed get series(): SlopeChartSeries[] {
return this.rawSeries.filter((series) =>
this.shouldSeriesBePlotted(series)
)
Expand Down

0 comments on commit 196784f

Please sign in to comment.