diff --git a/node-test/equal.test.js b/node-test/equal.test.js new file mode 100644 index 0000000..109d1f3 --- /dev/null +++ b/node-test/equal.test.js @@ -0,0 +1,6 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; + +test("1 + 2 = 3", () => { + assert.equal(1 + 2, 3); +}); diff --git a/node-test/hello.js b/node-test/hello.js new file mode 100644 index 0000000..86ec628 --- /dev/null +++ b/node-test/hello.js @@ -0,0 +1 @@ +export default "hello!"; diff --git a/node-test/hello.test.js b/node-test/hello.test.js new file mode 100644 index 0000000..5f72f11 --- /dev/null +++ b/node-test/hello.test.js @@ -0,0 +1,7 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import message from "./hello.js"; + +test("say hello", () => { + assert.equal(message, "hello!"); +}); diff --git a/node-test/package.json b/node-test/package.json new file mode 100644 index 0000000..d934865 --- /dev/null +++ b/node-test/package.json @@ -0,0 +1,9 @@ +{ + "type": "module", + "scripts": { + "test": "node --test" + }, + "engines": { + "node": "^18.7.0" + } +} diff --git a/node-test/parse-json.test.js b/node-test/parse-json.test.js new file mode 100644 index 0000000..9a01f07 --- /dev/null +++ b/node-test/parse-json.test.js @@ -0,0 +1,8 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; + +test("parse json", () => { + const json = `{"name": "太郎", "age": 42}`; + const obj = JSON.parse(json); + assert.deepEqual(obj, { name: "太郎", age: 42 }); +});