Remove actionTypes and check templates directly
This commit is contained in:
parent
3e713e8be8
commit
116a73c8d0
@ -68,26 +68,6 @@ const commands = [
|
|||||||
"/whois",
|
"/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 = [
|
const condensedTypes = [
|
||||||
"away",
|
"away",
|
||||||
"back",
|
"back",
|
||||||
@ -110,6 +90,5 @@ module.exports = {
|
|||||||
commands: commands,
|
commands: commands,
|
||||||
condensedTypes: condensedTypes,
|
condensedTypes: condensedTypes,
|
||||||
condensedTypesQuery: "." + condensedTypes.join(", ."),
|
condensedTypesQuery: "." + condensedTypes.join(", ."),
|
||||||
actionTypes: actionTypes,
|
|
||||||
timeFormats: timeFormats,
|
timeFormats: timeFormats,
|
||||||
};
|
};
|
||||||
|
@ -93,8 +93,7 @@ function buildChatMessage(msg) {
|
|||||||
msg.highlight = true;
|
msg.highlight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constants.actionTypes.indexOf(type) !== -1) {
|
if (typeof templates.actions[type] !== "undefined") {
|
||||||
msg.template = "actions/" + type;
|
|
||||||
template = "msg_action";
|
template = "msg_action";
|
||||||
} else if (type === "unhandled") {
|
} else if (type === "unhandled") {
|
||||||
template = "msg_unhandled";
|
template = "msg_unhandled";
|
||||||
|
@ -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() {
|
describe(".condensedTypes", function() {
|
||||||
it("should be a non-empty array", function() {
|
it("should be a non-empty array", function() {
|
||||||
expect(constants.condensedTypes).to.be.an("array").that.is.not.empty;
|
expect(constants.condensedTypes).to.be.an("array").that.is.not.empty;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be a subset of `actionTypes`", function() {
|
it("should only contain ASCII strings", function() {
|
||||||
expect(constants.actionTypes).to.include.members(constants.condensedTypes);
|
constants.condensedTypes.forEach((type) => {
|
||||||
|
expect(type).to.be.a("string").that.does.match(/^\w+$/);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user