kopia lustrzana https://github.com/drastus/sejm-calculator
Add Third Way coalition
rodzic
dd1c9c56a0
commit
410edf75a0
12
README.md
12
README.md
|
@ -1,2 +1,14 @@
|
||||||
# sejm-calculator
|
# sejm-calculator
|
||||||
Simulator for the Polish Sejm election
|
Simulator for the Polish Sejm election
|
||||||
|
|
||||||
|
Main libraries used:
|
||||||
|
* [Chartist](https://github.com/chartist-js/chartist)
|
||||||
|
* [Babel](https://github.com/babel/babel)
|
||||||
|
* [PostCSS](https://github.com/postcss/postcss)
|
||||||
|
* [Pug](https://github.com/pugjs/pug)
|
||||||
|
* [TypeScript](https://github.com/microsoft/TypeScript)
|
||||||
|
* [ESLint](https://github.com/eslint/eslint)
|
||||||
|
* [Stylelint](https://github.com/stylelint/stylelint)
|
||||||
|
* [Webpack 5](https://github.com/webpack/webpack)
|
||||||
|
* [Jest](https://github.com/jestjs/jest)
|
||||||
|
* [DOM Testing Library](https://github.com/testing-library/dom-testing-library)
|
||||||
|
|
17
src/data.ts
17
src/data.ts
|
@ -35,11 +35,11 @@ export const committees: Committee[] = [
|
||||||
pastSupportEquivalence: [['lewica', 1]],
|
pastSupportEquivalence: [['lewica', 1]],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'psl',
|
id: 'td',
|
||||||
name: 'PSL – Koalicja Polska',
|
name: 'Trzecia Droga',
|
||||||
shortName: 'PSL',
|
shortName: 'TD',
|
||||||
threshold: 5,
|
threshold: 8,
|
||||||
pastSupportEquivalence: [['psl', 1]],
|
pastSupportEquivalence: [['psl', 0.48], ['lewica', 0.23], ['konfederacja', 0.17], ['ko', 0.15], ['pis', 0.03]],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'konfederacja',
|
id: 'konfederacja',
|
||||||
|
@ -48,13 +48,6 @@ export const committees: Committee[] = [
|
||||||
threshold: 5,
|
threshold: 5,
|
||||||
pastSupportEquivalence: [['konfederacja', 1]],
|
pastSupportEquivalence: [['konfederacja', 1]],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'pl2050',
|
|
||||||
name: 'Polska 2050',
|
|
||||||
shortName: 'PL2050',
|
|
||||||
threshold: 5,
|
|
||||||
pastSupportEquivalence: [['psl', 0.24], ['lewica', 0.23], ['konfederacja', 0.17], ['ko', 0.15], ['pis', 0.03]],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'mn',
|
id: 'mn',
|
||||||
name: 'Mniejszość Niemiecka',
|
name: 'Mniejszość Niemiecka',
|
||||||
|
|
|
@ -164,18 +164,14 @@ h2 {
|
||||||
stroke: #d44;
|
stroke: #d44;
|
||||||
}
|
}
|
||||||
|
|
||||||
.psl {
|
.td {
|
||||||
stroke: #2ed397;
|
stroke: #8bd32e;
|
||||||
}
|
}
|
||||||
|
|
||||||
.konfederacja {
|
.konfederacja {
|
||||||
stroke: #655;
|
stroke: #655;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pl2050 {
|
|
||||||
stroke: #f9c013;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mn {
|
.mn {
|
||||||
stroke: #aaa;
|
stroke: #aaa;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ ol.updates
|
||||||
2020-10-28: dodano partię polityczną Polska 2050; jej prognozowane poparcie w okręgach jest
|
2020-10-28: dodano partię polityczną Polska 2050; jej prognozowane poparcie w okręgach jest
|
||||||
liczone na podstawie deklaracji wyborców Szymona Hołowni przedstawionych w artykule
|
liczone na podstawie deklaracji wyborców Szymona Hołowni przedstawionych w artykule
|
||||||
#[a(href='https://biqdata.wyborcza.pl/biqdata/7,159116,26083709,analiza-przeplywow-wyborcow-za-duda-tylko-pis-lewicowcy-nie.html') #[i Analiza przepływów wyborców]] z 29 czerwca 2020 roku.
|
#[a(href='https://biqdata.wyborcza.pl/biqdata/7,159116,26083709,analiza-przeplywow-wyborcow-za-duda-tylko-pis-lewicowcy-nie.html') #[i Analiza przepływów wyborców]] z 29 czerwca 2020 roku.
|
||||||
|
li.
|
||||||
|
2023-08-21: dodano koalicyjny komitet wyborczy Trzecia Droga (Polska 2050 + PSL – Koalicja Polska).
|
||||||
|
|
||||||
|
|
||||||
form#support-form
|
form#support-form
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
import calculateMandates from '../src/mandates';
|
import calculateMandates from '../src/mandates';
|
||||||
|
|
||||||
test('calculates correct results (1)', () => {
|
test('calculates correct results (1)', () => {
|
||||||
const support = [43.59, 27.4, 12.56, 8.55, 6.81, 0];
|
const support = [43.59, 27.4, 12.56, 8.55, 6.81];
|
||||||
const mandates = calculateMandates(support);
|
const mandates = calculateMandates(support);
|
||||||
|
|
||||||
expect(mandates).toEqual([235, 134, 49, 30, 11, 0, 1]);
|
expect(mandates).toEqual([237, 133, 48, 31, 10, 1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('calculates correct results (2)', () => {
|
test('calculates correct results (2)', () => {
|
||||||
const support = [30, 25, 10, 8, 6, 12];
|
const support = [30, 25, 10, 20, 6];
|
||||||
const mandates = calculateMandates(support);
|
const mandates = calculateMandates(support);
|
||||||
|
|
||||||
expect(mandates).toEqual([182, 133, 40, 34, 12, 58, 1]);
|
expect(mandates).toEqual([176, 131, 39, 104, 9, 1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('calculates correct results (3)', () => {
|
test('calculates correct results (3)', () => {
|
||||||
const support = [39.7, 42.4, 0, 0, 7.2, 0];
|
const support = [39.7, 42.4, 0, 0, 7.2];
|
||||||
const mandates = calculateMandates(support);
|
const mandates = calculateMandates(support);
|
||||||
|
|
||||||
expect(mandates).toEqual([225, 216, 0, 0, 18, 0, 1]);
|
expect(mandates).toEqual([225, 216, 0, 0, 18, 1]);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import {screen} from '@testing-library/dom';
|
import {screen} from '@testing-library/dom';
|
||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
import {generateTable} from '../src/display';
|
import {generateTable} from '../src/display';
|
||||||
|
import {committees} from '../src/data';
|
||||||
import html from '../src/templates/content.pug';
|
import html from '../src/templates/content.pug';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -9,7 +10,7 @@ beforeEach(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('display number inputs for electoral data', () => {
|
test('display number inputs for electoral data', () => {
|
||||||
const numberOfCommitees = 6;
|
const numberOfCommitees = committees.length - 1;
|
||||||
|
|
||||||
const numberInputs = screen.getAllByRole('spinbutton');
|
const numberInputs = screen.getAllByRole('spinbutton');
|
||||||
expect(numberInputs).toHaveLength(numberOfCommitees);
|
expect(numberInputs).toHaveLength(numberOfCommitees);
|
||||||
|
|
Ładowanie…
Reference in New Issue