Skip to content

Commit

Permalink
fix: bugfixes before launch
Browse files Browse the repository at this point in the history
  • Loading branch information
irony committed May 28, 2024
1 parent 3dec9f5 commit fd58d37
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/components/Seating.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 20 additions & 0 deletions src/lib/parliament.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/reducers/parties.mjs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 1 addition & 2 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import viteCompression from 'vite-plugin-compression'
import react from '@vitejs/plugin-react'

export default {
// config options
Expand All @@ -9,7 +8,7 @@ export default {
react: 'pureact/createElement',
},
},
plugins: [viteCompression(), react()],
plugins: [viteCompression()],
esbuild: {
jsxFactory: 'pureact.createElement',
jsxFragment: 'Fragment',
Expand Down

0 comments on commit fd58d37

Please sign in to comment.