From 5830a2e6d6a4226c4da2e5d6c75ec6bff1c6ce27 Mon Sep 17 00:00:00 2001 From: EliasMlopez99 Date: Sun, 10 Jul 2022 13:53:29 +0200 Subject: [PATCH] this solution doesn't contain a function --- .DS_Store | Bin 0 -> 6148 bytes src/.DS_Store | Bin 0 -> 6148 bytes src/elias-solution/.DS_Store | Bin 0 -> 6148 bytes src/elias-solution/elias-solution.js | 217 +++++++++++++++++++++++++++ 4 files changed, 217 insertions(+) create mode 100644 .DS_Store create mode 100644 src/.DS_Store create mode 100644 src/elias-solution/.DS_Store create mode 100644 src/elias-solution/elias-solution.js diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ff0871f724f36764a2607f43b360fdad87528da1 GIT binary patch literal 6148 zcmeHK&2G~`5S~o}b;4hekmv=;7j7X+XoJ)PQko`*NPrMVZ~)ZWaY$WUJBpn~B?RTp z6TpF2;5m2#o`n;9v%8?gX>Jul)sD3L&F;=OYk#(Py+kBhW4}&RCL#-ku~0&FhVeL; z70c-!<_VdjNvTkYN+_kp?{|RK5hdL)?s;MCA&wV` zU6krCY4C_P=n-{kk2>^(9O`7Ezh$Ct(vV!N5${kBFy}oAv0iXn&c$oTat3iHli_M6 z!#dul46jJfaE-gvrpLf49h0A#>1T#frV*|%MIA$%A^aX%0iD1*gP$8@_<68K)LWiK z>i2a)KON;wlA%`lyEhDjB(2qch+MvK>GFnUm8{aW(i`V6o;azSj+2%lm*~aA4>AD9`{OT+Ug{HCdRX{&D>&p42HQ9^;Mu7{U0Iv@=3S(2_T%lY# zP{|_zuz+r9@cB1^Ikv{8#<@a_z=Wa#6;I$(tGR5&GBAqqa2{H paok*?q@dE9K+0e$qrg8^;5VdWzj6Qo literal 0 HcmV?d00001 diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..04cf8c08f78dd090914e122d48cc34acf0bca15f GIT binary patch literal 6148 zcmeHK%}T>S5T30)R21paV_ra^S3!s+9=v$z3uu3+g(O>=G~g}Z^Y|9Ng3qJh>B%)81g@vw4UVv$e0x zCyDmed477mSYEzd?dl`*17tn=-BRYjSWkMqfFlvjv74&TFq zN-&$_tH@{wwii@<;g!dE`-xXnO^g9!z!>;326!)nbdChg8Ux0FF|cBQ_lF3|7%SF- zVe5biR{&re?jR`hZzAVJim_rXh!%*GRG_3fy<#{?hdy@RrF nTrIdtK_MK)h~=aB6dDBnhzr12u@-~}Vm|_b1~bOMuQKosnt5t~ literal 0 HcmV?d00001 diff --git a/src/elias-solution/.DS_Store b/src/elias-solution/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0fc5d71d5c6f33e77a026d65460949dc16caff9e GIT binary patch literal 6148 zcmeHKyH3PF44j24PNE4N<^BLj{K4vU6x93x98iEFQXJQ(01*;e3N)7N$xUh)yZ0Zqe6Uz4AO)m=6p#W^U{L|LCzRs1 zldqnR(gGEwfE1W2a2(6d`u`REm-&BMq?Htq0{=>ZvfAEkH+-e+t+SW2UR&w6^iN~1 or!#mfCVDI8!dmg!x4df4+;53vpqG>Pa-x0&Oc$9H_zML-0Mbz>EC2ui literal 0 HcmV?d00001 diff --git a/src/elias-solution/elias-solution.js b/src/elias-solution/elias-solution.js new file mode 100644 index 0000000..69ed902 --- /dev/null +++ b/src/elias-solution/elias-solution.js @@ -0,0 +1,217 @@ +/* eslint-disable sonarjs/no-duplicate-string */ +/* eslint-disable no-undef */ +// #todo + +/* 0. Starter Code + +*/ + +// =============== JSDoc description of the challenge =============== +/** + * The government is issuing corona money to healthcareworkers + * The actual premium has not been decided yet + * For doctors, the rules are as following: + * Less than 10-year experience: x1,5 + * More than 10 or equal: x2 + * More than 20 or equal: x3 + * Never more than: 1000 (throw an error) + * For nurses: + * Less than 10-year experience: x1,2 + * More than 10 or equal: x1,3 + * More than 15 or equal: x1,5 + * More than 20 or equal: x1,7 + * Never more than: 500 (throw an error) + * Any other profession should not get a premium (but no error should be thrown). + * + * { + profession: "nurse" | "doctor" | "therapist" | "psychologist" , + experience: 11 +}. + */ + +/** .......... + * Calculate the premium for healthcareworkers. + * + * -@param {object} - The healthcareworker object that is passed to the function. + * + * -@param {number} - The base premium. + * + * -@returns {number} - The premium rounded down to an integer. + */ + +// =============== your solutions will go here =============== +/** + * @param premium + * @param experience + */ + +// =============== a for-of loop to control which solution(s) are tested =============== + +for (const solution of [calculatePremium]) { + // =============== test cases for this challenge =============== + + // eslint-disable-next-line no-loop-func + describe(`${solution.name}: _`, () => { + // Nurse when premium 20 + // eslint-disable-next-line sonarjs/no-duplicate-string + describe('When the premium is 200', () => { + it('Should multiply by x1,2 when she has less than 10 years experience', () => { + expect(solution({ profession: 'nurse', experience: 8 }, 200)).toBe(240); + }); + }); + describe('When the premium is 200', () => { + it('Should multiply by x1,3 when she has more than 10 years or equal', () => { + expect(solution({ profession: 'nurse', experience: 10 }, 200)).toBe( + 260, + ); + }); + }); + describe('When the premium is 200', () => { + it('Should multiply by x1,5 when she has more than 15 years or equal', () => { + expect(solution({ profession: 'nurse', experience: 15 }, 200)).toBe( + 300, + ); + }); + }); + describe('When the premium is 200', () => { + it('Should multiply by x1,7 when she has more than 20 years or equal', () => { + expect(solution({ profession: 'nurse', experience: 15 }, 200)).toBe( + 340, + ); + }); + }); + describe('When the premium is 300', () => { + it('Should multiply by x1,2 when she has less than 10 years', () => { + expect(solution({ profession: 'nurse', experience: 8 }, 300)).toBe(360); + }); + }); + // eslint-disable-next-line sonarjs/no-duplicate-string + describe('when the premium is 300', () => { + // eslint-disable-next-line sonarjs/no-duplicate-string + it('should multiply by x1,3 when she has more than 10 years or equal', () => { + expect(solution({ profesion: 'nurse', experience: 10 }, 300)).toBe(390); + }); + }); + describe('when the premium is 300', () => { + it('should multiply by x1,5 when she has more than 15 years or equal', () => { + expect(solution({ profesion: 'nurse', experience: 15 }, 300)).toBe(450); + }); + }); + describe('when the premium is 300', () => { + it('should multiply by x1,7 when she has more than 15 years or equal', () => { + // eslint-disable-next-line no-unused-expressions + expect(solution({ profesion: 'nurse', experience: 20 }, 300)) + .toThrowError; + }); + }); + // nurse, and premium 400 + describe('when the premium is 400', () => { + it('should multiply by x1,2 when she has less than 10 years', () => { + expect(solution({ profesion: 'nurse', experience: 8 }, 400)).toBe(480); + }); + }); + describe('when the premium is 400', () => { + it('should multiply by x1,3 when she has more than 10 years or equal', () => { + expect(solution({ profesion: 'nurse', experience: 10 }, 400)).toThrow(); + }); + }); + describe('when the premium is 400', () => { + it('should multiply by x1,5 when she has less than 15 years or equal', () => { + expect(solution({ profesion: 'nurse', experience: 15 }, 400)).toThrow(); + }); + }); + describe('when the premium is 400', () => { + it('should multiply by x1,7 when she has less than 20 years or equal', () => { + expect(solution({ profesion: 'nurse', experience: 20 }, 400)).toThrow(); + }); + }); + // nurse when premium 500 + // eslint-disable-next-line sonarjs/no-duplicate-string + describe('when the premium is 500', () => { + it('should multiply by x1,2 when she has less than 10 years', () => { + expect(solution({ profesion: 'nurse', experience: 8 }, 500)).toThrow(); + }); + }); + describe('when the premium is 500', () => { + it('should multiply by x1,3 when she has more than 10 years or equal', () => { + expect(solution({ profesion: 'nurse', experience: 10 }, 500)).toThrow(); + }); + }); + describe('when the premium is 500', () => { + it('should multiply by x1,5 when she has more than 15 years or equal', () => { + expect(solution({ profesion: 'nurse', experience: 15 }, 500)).toThrow(); + }); + }); + describe('when the premium is 500', () => { + it('should multiply by x1,7 when she has more than 20 years or equal', () => { + expect(solution({ profesion: 'nurse', experience: 20 }, 500)).toThrow(); + }); + }); + // doctor when premium 200 + describe('when the premium is 200', () => { + // eslint-disable-next-line sonarjs/no-duplicate-string + it('should multiply by x1,5 when he has less than 10 years', () => { + expect(solution({ profesion: 'doctor', experience: 8 }, 200)).toBe(300); + }); + }); + describe('when the premium is 200', () => { + // eslint-disable-next-line sonarjs/no-duplicate-string + it('should multiply by x2 when he has more than 10 years or equal', () => { + expect(solution({ profesion: 'doctor', experience: 10 }, 200)).toBe( + 400, + ); + }); + }); + describe('when the premium is 200', () => { + it('should multiply by x3 when he has more than 20 years or equal', () => { + expect(solution({ profesion: 'doctor', experience: 20 }, 200)).toBe( + 600, + ); + }); + }); + // when doctor premium is 300 + describe('when the premium is 300', () => { + it('should multiply by x1,5 when he has less than 10 years', () => { + expect(solution({ profesion: 'doctor', experience: 8 }, 300)).toBe(450); + }); + }); + describe('when the premium is 300', () => { + it('should multiply by x2 when he has more than 10 years or equal', () => { + expect(solution({ profesion: 'doctor', experience: 10 }, 300)).toBe( + 600, + ); + }); + }); + describe('when the premium is 200', () => { + it('should multiply by x3 when he has more than 20 years or equal', () => { + expect(solution({ profesion: 'doctor', experience: 20 }, 300)).toBe( + 900, + ); + }); + }); + // when doctor premium is 500 + describe('when the premium is 500', () => { + it('should multiply by x1,5 when he has less than 10 years', () => { + expect(solution({ profesion: 'doctor', experience: 8 }, 500)).toBe(750); + }); + }); + describe('when the premium is 500', () => { + it('should multiply by x2 when he has more than 10 years or equal', () => { + expect(solution({ profesion: 'doctor', experience: 10 }, 500)).toBe( + 1000, + ); + }); + }); + describe('when the premium is 500', () => { + it('should multiply by x3 when he has more than 20 years or equal', () => { + expect( + solution({ profesion: 'doctor', experience: 20 }, 500), + ).toThrow(); + }); + }); + }); +} + +// =============== a minified solution you can use to test your test cases =============== + +// prettier-ignore``