From f01d492d95778b7e9126d355c9bf2c44a3e30785 Mon Sep 17 00:00:00 2001 From: Christoph Lienhard Date: Sun, 14 Jun 2020 20:52:30 +0200 Subject: [PATCH] Fix calculation of scores With this commit two calculation errors are fixed * the score in the case partyPosition = 'negative' while userPosition = 'neutral' shouldn't be MIN_POINTS but rather BASE_POINTS. * the totalScoredPoints (now "totalMaxPoints") should be independent of any party-positions which it wasn't. To minimize errors in this area in the future tests are added which are based on the official Rechenmodel of the bpb. To that end the score calculation logic was refactored and moved from results.vue to scoring.js, too. (cherry picked from commit 2d246fefbc4730ca5f7a4224325084a98f1c41f0) --- .eslintrc.js | 3 +- jest.config.js | 2 +- src/app/euromat/components/results.vue | 100 +++-------------------- src/app/euromat/scoring.js | 92 ++++++++++++++++++--- src/app/euromat/scoring.test.js | 109 +++++++++++++++++++++++++ 5 files changed, 206 insertions(+), 100 deletions(-) create mode 100644 src/app/euromat/scoring.test.js diff --git a/.eslintrc.js b/.eslintrc.js index 05a1ab6..13b6ecf 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,8 @@ module.exports = { root: true, env: { - node: true + node: true, + jest: true }, 'extends': [ 'plugin:vue/recommended', diff --git a/jest.config.js b/jest.config.js index 4ea9a9a..fa77ecf 100644 --- a/jest.config.js +++ b/jest.config.js @@ -20,7 +20,7 @@ module.exports = { 'jest-serializer-vue' ], testMatch: [ - '**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)' + '**/*.test.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)' ], testURL: 'http://localhost/' } diff --git a/src/app/euromat/components/results.vue b/src/app/euromat/components/results.vue index 44a1f56..b7311dd 100644 --- a/src/app/euromat/components/results.vue +++ b/src/app/euromat/components/results.vue @@ -32,7 +32,7 @@ @@ -99,17 +99,9 @@