-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
アバター取得は非同期であるべき、かつ 初期に設定すべき、なので プレイヤーに静的非同期メソッドで初期化する 外部でプレイヤーをインスタンス化する場合はNew関数を使用すること
- Loading branch information
1 parent
0b05fe1
commit 190cff4
Showing
2 changed files
with
42 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { IAccountRepository } from "infrastructure"; | ||
import { Avatar, Race } from "./Avatar"; | ||
import { Player, User } from "./User"; | ||
|
||
describe("User's functionality", () => { | ||
test("password hashing", () => { | ||
const cases = [ | ||
{ raw: "password", hash: "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8" }, | ||
{ raw: "cello", hash: "9bbf02efd82322aadc5d06c9bcf35bb4b0e3302ca158dc800407be1a4fea67e2" }, | ||
]; | ||
|
||
cases.forEach((c) => { | ||
expect(User.hashPassword(c.raw)).toBe(c.hash.toLowerCase()); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Player's functionality", () => { | ||
test("player level", () => { | ||
[ | ||
{ exp: 0, lv: 0 }, | ||
{ exp: 1250, lv: 5 }, | ||
{ exp: 5000, lv: 10 }, | ||
].forEach(async (c) => { | ||
const repoMock = jest.fn<Avatar, []>(() => new Avatar(Race.Egg, c.exp)); | ||
const p = await Player.New({ getAvatar: repoMock } as unknown as IAccountRepository, "", ""); | ||
const lv = p.level; | ||
expect(repoMock).toBeCalledTimes(1); | ||
expect(lv).toBe(c.lv); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters