From 3acd7ce269a5e8b8e3a945a86541e453744d6783 Mon Sep 17 00:00:00 2001 From: Mike Jumper Date: Thu, 4 May 2023 15:20:35 -0700 Subject: [PATCH] GUACAMOLE-615: Add unit tests for JS implementation of toInstruction(). --- .../src/test/javascript/ParserSpec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/guacamole-common-js/src/test/javascript/ParserSpec.js b/guacamole-common-js/src/test/javascript/ParserSpec.js index 8ab500ebe..9d59a63ba 100644 --- a/guacamole-common-js/src/test/javascript/ParserSpec.js +++ b/guacamole-common-js/src/test/javascript/ParserSpec.js @@ -203,4 +203,19 @@ describe('Guacamole.Parser', function ParserSpec() { }); + // Verify toInstruction() utility function correctly encodes instructions + describe('when an array of elements is provided to toInstruction()', function() { + + it('should return a correctly-encoded Guacamole instruction', function() { + expect(Guacamole.Parser.toInstruction([ 'test', 'instruction' ])).toBe('4.test,11.instruction;'); + expect(Guacamole.Parser.toInstruction([ 'test' + SURROGATE_PAIR, 'instruction' ])) + .toBe('5.test' + SURROGATE_PAIR + ',11.instruction;'); + expect(Guacamole.Parser.toInstruction([ UTF8_MULTIBYTE, HIGH_SURROGATE + 'xyz' + LOW_SURROGATE ])) + .toBe('4.' + UTF8_MULTIBYTE + ',5.' + HIGH_SURROGATE + 'xyz' + LOW_SURROGATE + ';'); + expect(Guacamole.Parser.toInstruction([ UTF8_MULTIBYTE, LOW_SURROGATE + 'xyz' + HIGH_SURROGATE ])) + .toBe('4.' + UTF8_MULTIBYTE + ',5.' + LOW_SURROGATE + 'xyz' + HIGH_SURROGATE + ';'); + }); + + }); + });