Skip to content

Commit b568ab7

Browse files
committed
初始化项目,添加失败测试
0 parents  commit b568ab7

File tree

7 files changed

+3457
-0
lines changed

7 files changed

+3457
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
node_modules/

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# TDD Dojo 环境预检查 - JS 版
2+
3+
请完成本代码库的运行并修复失败的测试。
4+
5+
## 环境要求
6+
7+
必须:
8+
9+
- NodeJS 12 以上版本
10+
- Yarn
11+
12+
推荐:
13+
14+
- WebStorm 或者 Visual Studio Code 最新版
15+
16+
## 运行方式
17+
18+
- 安装依赖 `yarn`
19+
- 运行测试 `yarn test`

babel.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
targets: {
7+
node: 'current',
8+
},
9+
},
10+
],
11+
],
12+
};
13+

package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "dojo",
3+
"version": "1.0.0",
4+
"description": "TDD dojo by extremeprogramming.cn",
5+
"main": "src/index.js",
6+
"author": "Kimmy",
7+
"license": "MIT",
8+
"scripts": {
9+
"test": "jest"
10+
},
11+
"devDependencies": {
12+
"@babel/core": "^7.7.5",
13+
"@babel/preset-env": "^7.7.6",
14+
"babel-jest": "^24.9.0",
15+
"jest": "^24.9.0"
16+
}
17+
}

src/Calculator.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
export default class Calculator {
3+
add(x, y) {
4+
return 0;
5+
}
6+
}

src/Calculator.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
import Calculator from "./Calculator"
3+
4+
describe("Calculator", () => {
5+
it("should equal to 2 when add 1 and 1", () => {
6+
const calculator = new Calculator()
7+
8+
const result = calculator.add(1, 1)
9+
10+
expect(result).toBe(2)
11+
})
12+
});

yarn.lock

Lines changed: 3388 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)