Remove actionTypes and check templates directly

This commit is contained in:
Pavel Djundik 2018-02-13 13:05:33 +02:00
parent 3e713e8be8
commit 116a73c8d0
3 changed files with 5 additions and 37 deletions

View File

@ -68,26 +68,6 @@ const commands = [
"/whois",
];
const actionTypes = [
"away",
"back",
"ban_list",
"invite",
"join",
"mode",
"kick",
"nick",
"part",
"quit",
"topic",
"topic_set_by",
"action",
"whois",
"ctcp",
"chghost",
"channel_list",
];
const condensedTypes = [
"away",
"back",
@ -110,6 +90,5 @@ module.exports = {
commands: commands,
condensedTypes: condensedTypes,
condensedTypesQuery: "." + condensedTypes.join(", ."),
actionTypes: actionTypes,
timeFormats: timeFormats,
};

View File

@ -93,8 +93,7 @@ function buildChatMessage(msg) {
msg.highlight = true;
}
if (constants.actionTypes.indexOf(type) !== -1) {
msg.template = "actions/" + type;
if (typeof templates.actions[type] !== "undefined") {
template = "msg_action";
} else if (type === "unhandled") {
template = "msg_unhandled";

View File

@ -30,25 +30,15 @@ describe("client-side constants", function() {
});
});
describe(".actionTypes", function() {
it("should be a non-empty array", function() {
expect(constants.actionTypes).to.be.an("array").that.is.not.empty;
});
it("should only contain strings with no whitespaces", function() {
constants.actionTypes.forEach((type) => {
expect(type).to.be.a("string").that.does.not.match(/\s/);
});
});
});
describe(".condensedTypes", function() {
it("should be a non-empty array", function() {
expect(constants.condensedTypes).to.be.an("array").that.is.not.empty;
});
it("should be a subset of `actionTypes`", function() {
expect(constants.actionTypes).to.include.members(constants.condensedTypes);
it("should only contain ASCII strings", function() {
constants.condensedTypes.forEach((type) => {
expect(type).to.be.a("string").that.does.match(/^\w+$/);
});
});
});