987ff560f5
Import initial monorepo structure for Nebula Core: add packages (@nebula/core, core-glyphs, core-input, core-navigation, core-theme, core-ui, core-utils) with source, dist, tests and assets. Expand README with overview, quick start and API snippets, and add package-level documentation files. Add jsconfig.json for path mapping, package.json and lockfiles to bootstrap the repo. This commit sets up the project layout, docs, and local package links for further development.
23 lines
599 B
JavaScript
23 lines
599 B
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { clamp, createEmitter } from "../src/index.js";
|
|
|
|
test("clamp keeps value within bounds", () => {
|
|
assert.equal(clamp(5, 0, 10), 5);
|
|
assert.equal(clamp(-1, 0, 10), 0);
|
|
assert.equal(clamp(99, 0, 10), 10);
|
|
});
|
|
|
|
test("createEmitter registers and emits", () => {
|
|
const emitter = createEmitter();
|
|
/** @type {Array<string>} */
|
|
const events = [];
|
|
|
|
const off = emitter.on((payload) => events.push(payload));
|
|
emitter.emit("confirm");
|
|
off();
|
|
emitter.emit("cancel");
|
|
|
|
assert.deepEqual(events, ["confirm"]);
|
|
});
|