|
| 1 | +// Import Node.js Dependencies |
| 2 | +import assert from "node:assert"; |
| 3 | +import { describe, it } from "node:test"; |
| 4 | + |
| 5 | +// Import Internal Dependencies |
| 6 | +import { stripNodePrefix } from "../../src/utils/index.ts"; |
| 7 | + |
| 8 | +describe("stripNodePrefix", () => { |
| 9 | + it("should remove 'node:' prefix from module name", () => { |
| 10 | + assert.strictEqual(stripNodePrefix("node:fs"), "fs"); |
| 11 | + assert.strictEqual(stripNodePrefix("node:path"), "path"); |
| 12 | + }); |
| 13 | + |
| 14 | + it("should return the value unchanged if no prefix is present", () => { |
| 15 | + assert.strictEqual(stripNodePrefix("fs"), "fs"); |
| 16 | + assert.strictEqual(stripNodePrefix("http"), "http"); |
| 17 | + }); |
| 18 | + |
| 19 | + it("should not modify similar but invalid prefixes", () => { |
| 20 | + assert.strictEqual(stripNodePrefix("nod:fs"), "nod:fs"); |
| 21 | + }); |
| 22 | + |
| 23 | + it("should only remove prefix at the beginning", () => { |
| 24 | + assert.strictEqual(stripNodePrefix("my-node:fs"), "my-node:fs"); |
| 25 | + }); |
| 26 | + |
| 27 | + it("should handle empty string", () => { |
| 28 | + assert.strictEqual(stripNodePrefix(""), ""); |
| 29 | + }); |
| 30 | + |
| 31 | + it("should return non-string values unchanged", () => { |
| 32 | + assert.strictEqual(stripNodePrefix(123), 123); |
| 33 | + assert.strictEqual(stripNodePrefix(null), null); |
| 34 | + assert.strictEqual(stripNodePrefix(undefined), undefined); |
| 35 | + |
| 36 | + const obj = { key: "value" }; |
| 37 | + assert.strictEqual(stripNodePrefix(obj), obj); |
| 38 | + }); |
| 39 | +}); |
0 commit comments