diff --git a/client/js/constants.js b/client/js/constants.js index 754a349b..1ce2f9e5 100644 --- a/client/js/constants.js +++ b/client/js/constants.js @@ -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, }; diff --git a/client/js/render.js b/client/js/render.js index 1530c52a..bf5d2e36 100644 --- a/client/js/render.js +++ b/client/js/render.js @@ -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"; diff --git a/test/client/js/constantsTest.js b/test/client/js/constantsTest.js index 5c44253f..f3140a89 100644 --- a/test/client/js/constantsTest.js +++ b/test/client/js/constantsTest.js @@ -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+$/); + }); }); });