16 lines
612 B
TypeScript
16 lines
612 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { neutralizeSpreadsheetFormula } from "./spreadsheet-safety.js";
|
|
|
|
describe("neutralizeSpreadsheetFormula", () => {
|
|
it.each(["=1+1", "+cmd", "-2+3", "@SUM(A1:A2)", " =1+1", "\tformula", "\rformula", "\nformula"])(
|
|
"neutralizes unsafe spreadsheet cell %j",
|
|
(value) => {
|
|
expect(neutralizeSpreadsheetFormula(value)).toBe(`'${value}`);
|
|
},
|
|
);
|
|
|
|
it.each(["", "plain text", " plain text", "1+1", "mailto:user@example.test"])("keeps safe cell %j unchanged", (value) => {
|
|
expect(neutralizeSpreadsheetFormula(value)).toBe(value);
|
|
});
|
|
});
|