Skip to content

Commit

Permalink
April opinion
Browse files Browse the repository at this point in the history
  • Loading branch information
hampusborgos committed Apr 22, 2024
1 parent ff2112c commit 611dcb6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Data/Polls.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
PublYearMonth,Company,M,L,C,KD,S,V,MP,SD,FI,Uncertain,n,PublDate,collectPeriodFrom,collectPeriodTo,approxPeriod,house
2024-apr,Verian,20.5,3.4,4.2,3.7,34.7,7.7,4.5,19.5,NA,NA,2994,2024-04-11,2024-03-25,2024-04-07,FALSE,Sifo
2024-apr,Demoskop,20.2,2.7,4.0,3.2,35.2,7.6,4.4,20.8,NA,NA,NA,2024-04-11,2024-03-24,2024-04-08,FALSE,Demoskop
2024-mar,Indikator,19.6,3.5,4.5,2.4,34.2,8.0,4.8,21.5,NA,NA,2413,2024-03-28,2024-03-04,2024-03-26,FALSE,Indikator
2024-mar,Ipsos,20,4,4,3,36,9,4,19,NA,NA,NA,2024-03-26,2024-03-12,2024-03-24,FALSE,Ipsos
2024-mar,Novus,19.5,3.1,4.6,3.8,36.2,7.8,4.6,19.1,NA,9.7,2230,2024-03-22,2024-02-19,2024-03-17,FALSE,Novus
2024-mar,Sentio,15.7,4.5,4.9,3.5,34.2,8.9,4.7,21.5,NA,NA,NA,2024-03-19,2024-03-10,2024-03-16,TRUE,Sentio
Expand Down
6 changes: 3 additions & 3 deletions polls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require('fs')
const Papa = require('papaparse')

const [header, ...polls] = Papa.parse(fs.readFileSync('Data/Polls.csv', { encoding: 'utf8' })).data.filter((poll) => poll.length > 1)
const newerPolls = polls.slice(0, 100)
const newerPolls = polls.slice(0, 70)
const allParties = ['M', 'L', 'C', 'KD', 'S', 'V', 'MP', 'SD', 'FI']

test('Header is correct', () => {
Expand Down Expand Up @@ -59,8 +59,8 @@ test('Newer poll trends make sense', () => {
expect(parties['L'], `L in (${poll}) has less than 2.0% support`).toBeGreaterThan(1.9)
expect(parties['L'], `L in (${poll}) has more than 7.7% support`).toBeLessThan(7.7)

expect(parties['KD'], `KD in (${poll}) has less than 2.6% support`).toBeGreaterThan(2.5)
expect(parties['KD'], `KD in (${poll}) has more than 7.5% support`).toBeLessThan(7.5)
expect(parties['KD'], `KD in (${poll}) has less than 2.3% support`).toBeGreaterThan(2.3)
expect(parties['KD'], `KD in (${poll}) has more than 6.2% support`).toBeLessThan(6.2)

expect(parties['C'], `C in (${poll}) has less than 3.2% support`).toBeGreaterThan(3.2)
expect(parties['C'], `C in (${poll}) has more than 8.9% support`).toBeLessThan(8.9)
Expand Down

0 comments on commit 611dcb6

Please sign in to comment.