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 96236e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 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,30 +7,22 @@ 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)
})

it("filters non-numeric values", () => {
const table = SynthesizeFruitTableWithStringValues(
{
Expand All @@ -44,6 +36,8 @@ it("filters non-numeric values", () => {
table,
yColumnSlugs: [SampleColumnSlugs.Fruit],
selection: table.availableEntityNames,
startTime: 2000,
endTime: 2001,
}
const chart = new SlopeChart({ manager })
expect(chart.series.length).toEqual(1)
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 96236e6

Please sign in to comment.