Files
wehub-resource-sync 6ede33ccdb
Build and Push Docker Images / create_manifest (web, surfsense-web, , cpu) (push) Has been cancelled
Build and Push Docker Images / finalize_release (push) Has been cancelled
Obsidian Plugin Lint / lint (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / compute_version (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / verify_digests (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, , cpu) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda, cuda) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda126, cuda126) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:33:44 +08:00

43 lines
1.5 KiB
TypeScript

/**
* Runnable self-check for the playground CSV serializer. No test framework —
* run with: ``npx tsx lib/playground/csv.selfcheck.ts``
* Exits non-zero on the first failed assertion.
*/
import assert from "node:assert/strict";
import { rowsToCsv } from "./csv";
// Union of keys, stable order, header + rows joined with CRLF.
assert.equal(
rowsToCsv([
{ a: 1, b: "x" },
{ a: 2, c: true },
]),
"a,b,c\r\n1,x,\r\n2,,true"
);
// Explicit columns fix order and subset.
assert.equal(rowsToCsv([{ a: 1, b: 2, c: 3 }], ["c", "a"]), "c,a\r\n3,1");
// RFC 4180 quoting: commas, quotes, and newlines.
assert.equal(rowsToCsv([{ v: 'he said "hi", bye' }]), 'v\r\n"he said ""hi"", bye"');
assert.equal(rowsToCsv([{ v: "line1\nline2" }]), 'v\r\n"line1\nline2"');
// Objects/arrays are JSON-stringified (then quoted for the comma).
assert.equal(rowsToCsv([{ v: { k: 1 } }]), 'v\r\n"{""k"":1}"');
// Null/undefined become empty cells.
assert.equal(rowsToCsv([{ v: null }]), "v\r\n");
// Formula-injection guard: dangerous leads get a ' prefix, real numbers don't.
assert.equal(rowsToCsv([{ v: "=1+2" }]), "v\r\n'=1+2");
assert.equal(rowsToCsv([{ v: "+1-800" }]), "v\r\n'+1-800");
assert.equal(rowsToCsv([{ v: "@handle" }]), "v\r\n'@handle");
assert.equal(rowsToCsv([{ v: "-cmd" }]), "v\r\n'-cmd");
assert.equal(rowsToCsv([{ v: "-5" }]), "v\r\n-5");
assert.equal(rowsToCsv([{ v: -5 }]), "v\r\n-5");
// Header only when there are no rows.
assert.equal(rowsToCsv([], ["a", "b"]), "a,b");
console.log("csv.selfcheck: all assertions passed");