mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 07:04:52 +09:00
Use lib* prefix for the modules impored from the lib package to help distinguish them more from ordinary variables. Fix up the naming convention for files to be consistently lowercase_underscore for JavaScript files.
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
"use strict";
|
|
const assert = require("assert").strict;
|
|
|
|
const libLuaTools = require("@clusterio/lib/lua_tools");
|
|
|
|
|
|
describe("lib/lua_tools", function() {
|
|
describe("escapeString()", function() {
|
|
it("should escape backslashes", function() {
|
|
assert.equal(libLuaTools.escapeString("\\a"), "\\\\a");
|
|
});
|
|
it("should escape double quotes", function() {
|
|
assert.equal(libLuaTools.escapeString('"a"'), '\\"a\\"');
|
|
});
|
|
it("should escape single quotes", function() {
|
|
assert.equal(libLuaTools.escapeString("'a'"), "\\'a\\'");
|
|
});
|
|
it("should escape nul bytes", function() {
|
|
assert.equal(libLuaTools.escapeString("a\0b"), "a\\0b");
|
|
});
|
|
it("should escape newlines", function() {
|
|
assert.equal(libLuaTools.escapeString("a\nb"), "a\\nb");
|
|
});
|
|
it("should escape carriage return", function() {
|
|
assert.equal(libLuaTools.escapeString("a\rb"), "a\\rb");
|
|
});
|
|
it("should escape all combined", function() {
|
|
assert.equal(libLuaTools.escapeString("a\\b\"c'd\0e\nf\rg"), "a\\\\b\\\"c\\'d\\0e\\nf\\rg");
|
|
});
|
|
});
|
|
});
|