Skip to content

Commit

Permalink
Added MOCK20tag option to sendChat() to trigger on("chat:message:[you…
Browse files Browse the repository at this point in the history
…r MOCK20tag]", func)
  • Loading branch information
kyleady committed Aug 27, 2017
1 parent aac512b commit 2dd5327
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 32 deletions.
1 change: 1 addition & 0 deletions Functions/API_Chat/SendChat.js
Expand Up @@ -31,6 +31,7 @@ var sendChat = function (speakingAs, input, callback, options) {
if (msgError) return;
if (typeof callback == 'function') return callback(msgs);
for (var msg of msgs) {
if(options.MOCK20tag) MOCK20trigger('chat:message:' + options.MOCK20tag, msg);
MOCK20trigger('chat:message', msg);
MOCK20log(JSON.stringify(msg), {}, 'ROLL20 CHAT');
}
Expand Down
32 changes: 0 additions & 32 deletions npm-debug.log

This file was deleted.

13 changes: 13 additions & 0 deletions test/Functions/API_Chat/sendChat_general.js
Expand Up @@ -162,4 +162,17 @@ describe('sendChat():general', function(){
expect(function(){sendChat('t', 2)}).to.throw();
expect(function(){sendChat(2, 't')}).to.throw();
});
it('should trigger on(\"chat:message:[your MOCK20tag]\", func)', function(){
var tagTriggered = false;
on('chat:message:tag_test', function(){
tagTriggered = true;
});
expect(tagTriggered).to.equal(false);
sendChat('Mock20', 'Untagged Message');
expect(tagTriggered).to.equal(false);
sendChat('Mock20', 'Tagged Message', null, {MOCK20tag: 'wrong_tag'});
expect(tagTriggered).to.equal(false);
sendChat('Mock20', 'Tagged Message', null, {MOCK20tag: 'tag_test'});
expect(tagTriggered).to.equal(true);
});
});

0 comments on commit 2dd5327

Please sign in to comment.