Skip to content

Commit

Permalink
Running prettier formatter on the project (#923)
Browse files Browse the repository at this point in the history
* npm run prettier

* npm run prettier

Run `npm run prettier`.
Add `yarn prettier` to qa.yml.

* Run only prettier check in CI
  • Loading branch information
ThePavolC authored Jul 24, 2024
1 parent 8755390 commit 6fa9217
Show file tree
Hide file tree
Showing 93 changed files with 2,405 additions and 1,814 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
- name: Lint
run: yarn lint

- name: Prettier
run: yarn prettier

- name: TypeScript
run: yarn check:ts

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Install dependencies:
```bash
yarn
```

Create environment variables:
```bash
cp .env.example .env
Expand Down
134 changes: 77 additions & 57 deletions __tests__/anonymize.test.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,82 @@
import { anoymizeChild } from "../src/components/Feedback"
import { anoymizeChild } from '../src/components/Feedback'

describe('anonymize', () => {
describe('#annoymizeChild', () => {
const scenarios = [
{ input: {
id: 1,
priezviskoMeno: '',
rodneCislo: '901006 / 6472',
describe('#annoymizeChild', () => {
const scenarios = [
{
input: {
id: 1,
priezviskoMeno: '',
rodneCislo: '901006 / 6472',

wholeYear: false,
monthFrom: '0',
monthTo: '11',
}, month: 10, year: 1990 },
{ input: {
id: 1,
priezviskoMeno: '',
rodneCislo: '050426 / 9744',

wholeYear: false,
monthFrom: '0',
monthTo: '11',
}, month: 4, year: 2005 },
{ input: {
id: 1,
priezviskoMeno: '',
rodneCislo: '705426 / 0169',

wholeYear: false,
monthFrom: '0',
monthTo: '11',
}, month: 4, year: 1970 },
{ input: {
id: 1,
priezviskoMeno: '',
rodneCislo: '185717 / 4924',

wholeYear: false,
monthFrom: '0',
monthTo: '11',
}, month: 7, year: 2018 },
{ input: {
id: 1,
priezviskoMeno: '',
rodneCislo: '646118 / 6369',

wholeYear: false,
monthFrom: '0',
monthTo: '11',
}, month: 11, year: 1964 },
]
wholeYear: false,
monthFrom: '0',
monthTo: '11',
},
month: 10,
year: 1990,
},
{
input: {
id: 1,
priezviskoMeno: '',
rodneCislo: '050426 / 9744',

scenarios.forEach(({ input, month, year }) => {
it(`From personalID ${input.rodneCislo} get month ${month} and year ${year}`, () => {
const anonym = anoymizeChild(input)
expect(anonym.mesiacNarodenia).toBe(month)
expect(anonym.rokNarodenia).toBe(year)
expect(anonym.rodneCislo).toBe("anon")
})
})
wholeYear: false,
monthFrom: '0',
monthTo: '11',
},
month: 4,
year: 2005,
},
{
input: {
id: 1,
priezviskoMeno: '',
rodneCislo: '705426 / 0169',

wholeYear: false,
monthFrom: '0',
monthTo: '11',
},
month: 4,
year: 1970,
},
{
input: {
id: 1,
priezviskoMeno: '',
rodneCislo: '185717 / 4924',

wholeYear: false,
monthFrom: '0',
monthTo: '11',
},
month: 7,
year: 2018,
},
{
input: {
id: 1,
priezviskoMeno: '',
rodneCislo: '646118 / 6369',

wholeYear: false,
monthFrom: '0',
monthTo: '11',
},
month: 11,
year: 1964,
},
]

scenarios.forEach(({ input, month, year }) => {
it(`From personalID ${input.rodneCislo} get month ${month} and year ${year}`, () => {
const anonym = anoymizeChild(input)
expect(anonym.mesiacNarodenia).toBe(month)
expect(anonym.rokNarodenia).toBe(year)
expect(anonym.rodneCislo).toBe('anon')
})
})
})
})
})
9 changes: 4 additions & 5 deletions __tests__/calcIntegration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ const WRITE_FILES = false
const comparable = (xml: string) =>
parseStringPromise(xml, { trim: true, normalize: true, normalizeTags: true })


const testCases = readdirSync('./__tests__/testCases/', {withFileTypes: true})
.filter(item => !item.isDirectory())
.map(item => item.name)
.map(item => item.replace('Input.ts', ''))
const testCases = readdirSync('./__tests__/testCases/', { withFileTypes: true })
.filter((item) => !item.isDirectory())
.map((item) => item.name)
.map((item) => item.replace('Input.ts', ''))

describe('calcIntergration', () => {
testCases.forEach((testCase) => {
Expand Down
13 changes: 0 additions & 13 deletions __tests__/calculation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,37 +126,31 @@ describe('With child (for tax year 2022)', () => {
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// ) // kazdy mesiac ked vek < 6 rokov

// expect(result.r117a).toEqual(monthSums)
// })

// test('Child turning 6 in 2022 (february)', () => {
// const result = calculate({
// ...initTaxFormUserInputValues,
// hasChildren: true,
// children: [childTurning6InFeb],
// t1r10_prijmy: MIN_PRIJEM_NA_DANOVY_BONUS_NA_DIETA.toString(),
// })

// const monthSums = sum(
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// )

// expect(result.r117a).toEqual(monthSums)
// })

// test('Child turning 6 in 2022 (july)', () => {
// const result = calculate({
// ...initTaxFormUserInputValues,
// hasChildren: true,
// children: [childTurning6InJul],
// t1r10_prijmy: MIN_PRIJEM_NA_DANOVY_BONUS_NA_DIETA.toString(),
// })

// const part1 = sum(
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
Expand All @@ -166,15 +160,13 @@ describe('With child (for tax year 2022)', () => {
// ) // februar - jul (vek do 6 rokov vratane mesiaca dovrsenia) ale jul uz patri do druhej polovice roka
// expect(result.r117a).toEqual(part1)
// })

// test('Child over 6', () => {
// const result = calculate({
// ...initTaxFormUserInputValues,
// hasChildren: true,
// children: [childOver6],
// t1r10_prijmy: (15_000).toString(),
// })

// const monthSums = sum(
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
Expand All @@ -188,7 +180,6 @@ describe('With child (for tax year 2022)', () => {
// ) // vek nad 6 rokov vratane mesiaca dovrsenia
// expect(result.r117).toEqual(monthSums)
// })

// test('More children', () => {
// const result = calculate({
// ...initTaxFormUserInputValues,
Expand All @@ -201,7 +192,6 @@ describe('With child (for tax year 2022)', () => {
// ],
// t1r10_prijmy: (25_000).toString(),
// })

// // childOver6
// const childOver6Sum = sum(
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
Expand All @@ -214,7 +204,6 @@ describe('With child (for tax year 2022)', () => {
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// )

// // childTurning6InFeb
// const childTurning6InFebSum = sum(
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
Expand All @@ -227,7 +216,6 @@ describe('With child (for tax year 2022)', () => {
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// )

// // childTurning6InJul
// const childTurning6InJulSum = sum(
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
Expand All @@ -240,7 +228,6 @@ describe('With child (for tax year 2022)', () => {
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// ) // januar - jul (vek do 6 rokov vratane mesiaca dovrsenia)

// // childUnder6
// const childUnder6Sum = sum(
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
Expand Down
12 changes: 6 additions & 6 deletions __tests__/dve-percenta.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,38 @@ describe('dve-percenta', () => {
input: { dve_percenta_podporujem: undefined },
expected: ['dve_percenta_podporujem'],
},
{ input: { dve_percenta_podporujem: "nie" }, expected: [] },
{ input: { dve_percenta_podporujem: 'nie' }, expected: [] },
{
input: { dve_percenta_podporujem: "ano-inu" },
input: { dve_percenta_podporujem: 'ano-inu' },
expected: ['r142_ico', 'r142_obchMeno'],
},
{
input: {
dve_percenta_podporujem: "ano-inu",
dve_percenta_podporujem: 'ano-inu',
r142_ico: '1',
r142_obchMeno: 'Fake, o.z.',
},
expected: [],
},
{
input: {
dve_percenta_podporujem: "ano-inu",
dve_percenta_podporujem: 'ano-inu',
r142_ico: '12 345 67',
r142_obchMeno: 'Fake, o.z.',
},
expected: [],
},
{
input: {
dve_percenta_podporujem: "ano-inu",
dve_percenta_podporujem: 'ano-inu',
r142_ico: '12 345 678',
r142_obchMeno: 'Fake, o.z.',
},
expected: [],
},
{
input: {
dve_percenta_podporujem: "ano-inu",
dve_percenta_podporujem: 'ano-inu',
r142_ico: '12 345 6',
r142_obchMeno: 'Fake, o.z.',
},
Expand Down
Loading

0 comments on commit 6fa9217

Please sign in to comment.