This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
137 additions
and
112 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,18 @@ | ||
import { describe, test, expect } from "vitest"; | ||
import { func1, func2 } from "../../basic/script"; | ||
|
||
describe("ループ・配列の問題", () => { | ||
test("func1", () => expect(func1(5)).toEqual([1, 2, 3, 4, 5])); | ||
test("func1", () => expect(func1(8)).toEqual([1, 2, 3, 4, 5, 6, 7, 8])); | ||
test("func1", () => expect(func1(-1)).toEqual([])); | ||
}); | ||
|
||
describe("条件分岐・データ型の問題", () => { | ||
test("func2", () => expect(func2(1)).toEqual("1")); | ||
test("func2", () => expect(func2(3)).toEqual("Fizz")); | ||
test("func2", () => expect(func2(5)).toEqual("Buzz")); | ||
test("func2", () => expect(func2(15)).toEqual("FizzBuzz")); | ||
test("func2", () => expect(func2(22)).toEqual("22")); | ||
test("func2", () => expect(func2(30)).toEqual("FizzBuzz")); | ||
test("func2", () => expect(func2("hogehoge")).toEqual("error")); | ||
}); |
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
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,14 @@ | ||
import { describe, test, expect } from "vitest"; | ||
import { func1, func2 } from "../../function/script"; | ||
|
||
describe("関数型プログラミングの問題1", () => { | ||
test("正しい結果が返ってきている", () => { | ||
expect(func1()).toEqual(["Ken", "Hana"]); | ||
}); | ||
}); | ||
|
||
describe("関数型プログラミングの問題2", () => { | ||
test("正しい結果が返ってきている", () => { | ||
expect(func2()).toEqual(125); | ||
}); | ||
}); |
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,37 @@ | ||
import { describe, test, expect } from "vitest"; | ||
import { func1, func2, func3 } from "../../object/script"; | ||
|
||
describe("オブジェクトの問題1", () => { | ||
test("正しい結果が返ってきている", () => { | ||
expect(func1()).toMatchObject({ | ||
firstName: "Ken", | ||
lastName: "Takahashi", | ||
age: 29, | ||
gender: "male", | ||
interests: [ | ||
{ | ||
name: "programming", | ||
emoji: "💻", | ||
}, | ||
{ | ||
name: "motorcycle", | ||
emoji: "🏍", | ||
}, | ||
], | ||
}); | ||
}); | ||
}); | ||
|
||
describe("オブジェクトの問題2", () => { | ||
test("正しい結果が返ってきている", () => { | ||
expect(func2()).toEqual( | ||
'{"firstName":"Ken","lastName":"Takahashi","age":29}' | ||
); | ||
}); | ||
}); | ||
|
||
describe("オブジェクトの問題3", () => { | ||
test("正しい結果が返ってきている", () => { | ||
expect(func3()).toEqual("Leanne Graham,[email protected]"); | ||
}); | ||
}); |
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,66 @@ | ||
import { describe, test, expect, vi } from "vitest"; | ||
import { func1, func2, func3 } from "../../promise/script"; | ||
|
||
const results = [ | ||
{ | ||
userId: 1, | ||
id: 1, | ||
title: "delectus aut autem", | ||
completed: false, | ||
}, | ||
{ | ||
userId: 1, | ||
id: 2, | ||
title: "quis ut nam facilis et officia qui", | ||
completed: false, | ||
}, | ||
{ | ||
userId: 1, | ||
id: 3, | ||
title: "fugiat veniam minus", | ||
completed: false, | ||
}, | ||
{ | ||
userId: 1, | ||
id: 4, | ||
title: "et porro tempora", | ||
completed: true, | ||
}, | ||
{ | ||
userId: 1, | ||
id: 5, | ||
title: "laboriosam mollitia et enim quasi adipisci quia provident illum", | ||
completed: false, | ||
}, | ||
]; | ||
|
||
describe("非同期処理の問題", () => { | ||
test("正しい値が取得できている", async () => { | ||
const json = await func1(); | ||
expect(json).toMatchObject(results[0]); | ||
}); | ||
}); | ||
|
||
describe("非同期処理の問題 - 直列処理", () => { | ||
test("正しい順番で実行できている", async () => { | ||
const spy = vi | ||
.spyOn(global.console, "log") | ||
.mockImplementation((args) => args); | ||
await func2(); | ||
for (const result of results) { | ||
expect(spy).toHaveReturnedWith(result); | ||
} | ||
}); | ||
}); | ||
|
||
describe("非同期処理の問題 - 並列処理", () => { | ||
test("正しい値が取得できている", async () => { | ||
const json = await func3(); | ||
expect(json).toMatchObject(results); | ||
}); | ||
test("Promise.allが使われている", async () => { | ||
const spy = vi.spyOn(Promise, "all"); | ||
await func3(); | ||
expect(spy).toHaveBeenCalled(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.