|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | + |
| 3 | +import { |
| 4 | + formatHeader, |
| 5 | + formatReformLine, |
| 6 | +} from "@prn-parking-lots/shared/src/js/city-ui/scorecard.ts"; |
| 7 | + |
| 8 | +import formatScorecard, { COMMUNITY_WARNING } from "../src/js/scorecard.ts"; |
| 9 | + |
| 10 | +test.describe("formatScorecard", () => { |
| 11 | + test("full stats", () => { |
| 12 | + const { header, listEntries } = formatScorecard({ |
| 13 | + name: "Hartford, CT", |
| 14 | + percentage: "25%", |
| 15 | + population: "42,412", |
| 16 | + reforms: "adopted", |
| 17 | + url: "https://parkingreform.org", |
| 18 | + cityType: "suburb", |
| 19 | + urbanizedAreaPopulation: "104,241", |
| 20 | + parkingScore: "88", |
| 21 | + contribution: "email@parkingreform.org", |
| 22 | + }); |
| 23 | + expect(header).toEqual( |
| 24 | + formatHeader({ |
| 25 | + name: "Hartford, CT", |
| 26 | + percentage: "25%", |
| 27 | + boundaryDescription: "central city", |
| 28 | + }) + COMMUNITY_WARNING, |
| 29 | + ); |
| 30 | + expect(listEntries).toEqual([ |
| 31 | + "88/100 parking score (lower is better)", |
| 32 | + "City type: suburb", |
| 33 | + "42,412 city residents", |
| 34 | + "104,241 urbanized area residents", |
| 35 | + formatReformLine("adopted", "https://parkingreform.org"), |
| 36 | + `<a href="mailto:email@parkingreform.org">Email data maintainer</a>`, |
| 37 | + ]); |
| 38 | + }); |
| 39 | + |
| 40 | + test("minimal stats", () => { |
| 41 | + const { header, listEntries } = formatScorecard({ |
| 42 | + name: "Hartford, CT", |
| 43 | + percentage: "25%", |
| 44 | + population: "42,412", |
| 45 | + reforms: null, |
| 46 | + url: null, |
| 47 | + cityType: "suburb", |
| 48 | + urbanizedAreaPopulation: "104,241", |
| 49 | + parkingScore: null, |
| 50 | + contribution: null, |
| 51 | + }); |
| 52 | + expect(header).toEqual( |
| 53 | + formatHeader({ |
| 54 | + name: "Hartford, CT", |
| 55 | + percentage: "25%", |
| 56 | + boundaryDescription: "central city", |
| 57 | + }), |
| 58 | + ); |
| 59 | + expect(listEntries).toEqual([ |
| 60 | + "City type: suburb", |
| 61 | + "42,412 city residents", |
| 62 | + "104,241 urbanized area residents", |
| 63 | + ]); |
| 64 | + }); |
| 65 | +}); |
0 commit comments