From 525c4768542f03c7fa6698ae7386d9fa523cfd06 Mon Sep 17 00:00:00 2001 From: Mike Jumper Date: Thu, 27 Apr 2023 08:44:39 -0700 Subject: [PATCH] GUACAMOLE-615: Add unit tests for JS parser in buffer mode. --- .../src/test/javascript/ParserSpec.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/guacamole-common-js/src/test/javascript/ParserSpec.js b/guacamole-common-js/src/test/javascript/ParserSpec.js index 34ca13c70..2e2b25b55 100644 --- a/guacamole-common-js/src/test/javascript/ParserSpec.js +++ b/guacamole-common-js/src/test/javascript/ParserSpec.js @@ -158,6 +158,20 @@ describe('Guacamole.Parser', function ParserSpec() { }); + // Instruction fed via blocks of characters that accumulate via an external + // buffer + describe('when an instruction is received via an external buffer', function() { + it('should correctly parse each element and invoke oninstruction once ready', function() { + parser.oninstruction = jasmine.createSpy('oninstruction'); + parser.receive('5.test2,10.hello', true); + expect(parser.oninstruction).not.toHaveBeenCalled(); + parser.receive('5.test2,10.hellohello,15', true); + expect(parser.oninstruction).not.toHaveBeenCalled(); + parser.receive('5.test2,10.hellohello,15.worldworldworld;', true); + expect(parser.oninstruction).toHaveBeenCalledOnceWith('test2', [ 'hellohello', 'worldworldworld' ]); + }); + + }); });