thelounge/test/tests/textLogFolder.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

"use strict";
const expect = require("chai").expect;
const TextFileMessageStorage = require("../../src/plugins/messageStorage/text");
describe("TextFileMessageStorage", function () {
2021-05-23 00:55:47 +02:00
const store = new TextFileMessageStorage();
it("should combine network name and uuid into a safe name", function () {
2019-07-17 11:33:59 +02:00
expect(
2021-05-23 00:55:47 +02:00
store._getNetworkFolderName({
2019-07-17 11:33:59 +02:00
name: "Freenode",
uuid: "f9042ec9-4016-45e0-a8a8-d378fb252628",
})
).to.equal("freenode-4016-45e0-a8a8-d378fb252628");
});
it("network name should be cleaned up and lowercased", function () {
2019-07-17 11:33:59 +02:00
expect(
2021-05-23 00:55:47 +02:00
store._getNetworkFolderName({
2019-07-17 11:33:59 +02:00
name: '@ TeSt ../..\\<>:"/\\|?*',
uuid: "f9042ec9-4016-45e0-a8a8-d378fb252628",
})
).to.equal("@-test-.._..--45e0-a8a8-d378fb252628");
});
it("folder name may contain two dashes if on boundary", function () {
2019-07-17 11:33:59 +02:00
expect(
2021-05-23 00:55:47 +02:00
store._getNetworkFolderName({
2019-07-17 11:33:59 +02:00
name: "Freenod",
uuid: "f9042ec9-4016-45e0-a8a8-d378fb252628",
})
).to.equal("freenod--4016-45e0-a8a8-d378fb252628");
});
it("should limit network name length", function () {
2019-07-17 11:33:59 +02:00
expect(
2021-05-23 00:55:47 +02:00
store._getNetworkFolderName({
2019-07-17 11:33:59 +02:00
name: "This network name is longer than the uuid itself but it should be limited",
uuid: "f9042ec9-4016-45e0-a8a8-d378fb252628",
})
).to.equal("this-network-name-is-lo-d378fb252628");
});
});