From fd58d37372d379b80555659c084a4af359775750 Mon Sep 17 00:00:00 2001 From: Christian Landgren Date: Tue, 28 May 2024 10:28:01 +0200 Subject: [PATCH] fix: bugfixes before launch --- src/components/Seating.jsx | 6 ++++-- src/lib/parliament.test.mjs | 20 ++++++++++++++++++++ src/reducers/parties.mjs | 3 +-- vite.config.js | 3 +-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/components/Seating.jsx b/src/components/Seating.jsx index 1dafbf2..7abadc2 100644 --- a/src/components/Seating.jsx +++ b/src/components/Seating.jsx @@ -8,7 +8,9 @@ const obj = (parties) => {} ) -const Seating = ({ parties, seatCount = true }) => - parliamentSVG(obj(parties), seatCount) +const Seating = ({ parties, seatCount = true }) => { + console.log('seating', parties, seatCount) + return parliamentSVG(obj(parties), seatCount) +} export default Seating diff --git a/src/lib/parliament.test.mjs b/src/lib/parliament.test.mjs index a235255..67b0bcf 100644 --- a/src/lib/parliament.test.mjs +++ b/src/lib/parliament.test.mjs @@ -194,6 +194,26 @@ it('should update based on percentage but not not touch changed parties', () => expect(Math.round(result[2].percentage)).toBe(4) }) +it('should be able to have a different amount of seats', () => { + const parliament = new Parliament(state.parties, 100) + const result = parliament.seats + expect(result).toHaveLength(2) + expect(result[0]).toHaveProperty('seats') + expect(result[1]).toHaveProperty('seats') + expect(result[0].seats).toBe(50) + expect(result[1].seats).toBe(50) +}) + +it('should be able to have a EU parliament amount of seats', () => { + const parliament = new Parliament(state.parties, 21) + const result = parliament.seats + expect(result).toHaveLength(2) + expect(result[0]).toHaveProperty('seats') + expect(result[1]).toHaveProperty('seats') + expect(result[0].seats).toBe(11) + expect(result[1].seats).toBe(10) +}) + it.skip('should mix seats from each party evenly when they have equally amount of votes', () => { const parliament = new Parliament(state.parties) const result = parliament.seats diff --git a/src/reducers/parties.mjs b/src/reducers/parties.mjs index 00a8668..97173c4 100644 --- a/src/reducers/parties.mjs +++ b/src/reducers/parties.mjs @@ -1,7 +1,6 @@ import { Parliament } from '../lib/parliament.mjs' -import polls from '../lib/polls.mjs' -const SEATS = import.meta.env.VITE_PARLIAMENT_SEATS || 349 +const SEATS = parseFloat(import.meta.env.VITE_PARLIAMENT_SEATS || 349) const parties = [ { id: 1, diff --git a/vite.config.js b/vite.config.js index 6e4ae38..2af266c 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,5 +1,4 @@ import viteCompression from 'vite-plugin-compression' -import react from '@vitejs/plugin-react' export default { // config options @@ -9,7 +8,7 @@ export default { react: 'pureact/createElement', }, }, - plugins: [viteCompression(), react()], + plugins: [viteCompression()], esbuild: { jsxFactory: 'pureact.createElement', jsxFragment: 'Fragment',