import { test } from 'node:test' import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' import * as mod from '../../../web/js/skills.js' // the code under test: call it as mod.(...) const source = readFileSync(new URL('../../../web/js/skills.js', import.meta.url), 'utf8') // the text of web/js/skills.js, for a criterion about how the file is written test('criterion 1', () => { // `parseSkill("---\r\nname: demo\r\ndescription: x\r\n---\r\nBody")` returns `{ name: "demo", description: "x", content: "Body" }`. assert.deepEqual(mod.parseSkill("---\r\nname: demo\r\ndescription: x\r\n---\r\nBody"), { name: "demo", description: "x", content: "Body" }) }) test('criterion 2', () => { // `parseSkill("---\nname: demo\ndescription: x\n---\nBody")` returns `{ name: "demo", description: "x", content: "Body" }`. assert.deepEqual(mod.parseSkill("---\nname: demo\ndescription: x\n---\nBody"), { name: "demo", description: "x", content: "Body" }) }) test('criterion 3', () => { // `parseSkill("Body only", "fallback")` returns `{ name: "fallback", description: "", content: "Body only" }`. assert.deepEqual(mod.parseSkill("Body only", "fallback"), { name: "fallback", description: "", content: "Body only" }) })