Skip to content

Commit

Permalink
add test infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
as.zaycev committed Feb 14, 2022
1 parent a29c5d0 commit fa3ee40
Show file tree
Hide file tree
Showing 10 changed files with 15,273 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/src/Classes.d.ts
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx pretty-quick --staged
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "all",
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"arrowParens": "always"
}
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Basic Syntax

Установите зависимости:

```
npm install
```

В файле `src/BasicSyntax.js` в функции `romanToInteger` напишите код, преобразующий число из римской записи в арабскую. На вход вы получите строку, ответом должно быть число.

| Символ | Значение |
| ------ | -------- |
| I | 1 |
| V | 5 |
| X | 10 |
| L | 50 |
| C | 100 |
| D | 500 |
| M | 1000 |

Проверить себя можно запустив команду `npm run test`.

После выполнения задания создайте pull request с решением.
15,154 changes: 15,154 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "task-basic-syntax",
"version": "0.1.0",
"private": true,
"dependencies": {
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"typescript": "^4.1.2"
},
"scripts": {
"test": "react-scripts test",
"lint": "eslint ./src",
"prepare": "husky install"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"husky": "^7.0.0",
"prettier": "^2.4.1",
"pretty-quick": "^3.1.1"
}
}
8 changes: 8 additions & 0 deletions src/BasicSyntax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function romanToInteger(str) {
let result = 0;
/*
Напишите код, преобразующий число из римской записи в арабскую.
На вход вы получите строку, ответом должно быть число.
*/
return result;
}
11 changes: 11 additions & 0 deletions src/BasicSyntax.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { romanToInteger } from './BasicSyntax';

describe('Базовый синтаксис', () => {
it('Преобразование римских чисел в арабские', () => {
expect(romanToInteger('II')).toBe(2);
expect(romanToInteger('XVI')).toBe(16);
expect(romanToInteger('XXXVII')).toBe(37);
expect(romanToInteger('MMMCDXLIV')).toBe(3444);
expect(romanToInteger('MCMXCIX')).toBe(1999);
});
});
1 change: 1 addition & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
20 changes: 20 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"]
}

0 comments on commit fa3ee40

Please sign in to comment.