-
Notifications
You must be signed in to change notification settings - Fork 200
Expand file tree
/
Copy pathcar.test.js
More file actions
36 lines (28 loc) · 944 Bytes
/
car.test.js
File metadata and controls
36 lines (28 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Car } from "../src/Car.js";
describe("Car 클래스", () => {
test("자동차는 이름과 초기 위치를 가진다", () => {
const car = new Car("pobi");
expect(car.name).toBe("pobi");
expect(car.position).toBe(0);
});
test("randomValue가 4인 경우 canMove는 true를 반환한다.", () => {
const car = new Car("pobi");
expect(car.canMove(4)).toBe(true);
});
test("randomValue가 3인 경우 canMove는 false를 반환한다.", () => {
const car = new Car("pobi");
expect(car.canMove(3)).toBe(false);
});
test("move()를 호출하면 position이 1 증가한다", () => {
const car = new Car("pobi");
car.move();
expect(car.position).toBe(1);
});
test("move()를 여러 번 호출하면 그 횟수만큼 position이 증가한다", () => {
const car = new Car("pobi");
car.move();
car.move();
car.move();
expect(car.position).toBe(3);
});
});