mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-24 00:50:44 +00:00
26 lines
831 B
TypeScript
26 lines
831 B
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { importVaultHostsFromText } from "../vaultImport.ts";
|
|
import { exportHostsToCsvWithStats } from "./csvExport.ts";
|
|
import type { Host } from "../models.ts";
|
|
|
|
test("CSV exports include a UTF-8 BOM and preserve Chinese text when imported again", () => {
|
|
const host: Host = {
|
|
id: "host-1",
|
|
label: "中文服务器",
|
|
hostname: "10.0.0.1",
|
|
username: "root",
|
|
port: 22,
|
|
};
|
|
|
|
const { csv } = exportHostsToCsvWithStats([host]);
|
|
|
|
assert.equal(csv.charCodeAt(0), 0xfeff);
|
|
assert.deepEqual([...new TextEncoder().encode(csv).slice(0, 3)], [0xef, 0xbb, 0xbf]);
|
|
|
|
const imported = importVaultHostsFromText("csv", csv);
|
|
assert.equal(imported.hosts[0]?.label, host.label);
|
|
assert.equal(imported.hosts[0]?.hostname, host.hostname);
|
|
});
|