From e4f222f6b00ed853895b154f65c86d0a2a742312 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Tue, 9 Sep 2025 12:03:51 -0700 Subject: [PATCH] Make test happy --- src/common/services/CoreMouseService.test.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/common/services/CoreMouseService.test.ts b/src/common/services/CoreMouseService.test.ts index 34710897..3b79596d 100644 --- a/src/common/services/CoreMouseService.test.ts +++ b/src/common/services/CoreMouseService.test.ts @@ -3,13 +3,14 @@ * @license MIT */ import { CoreMouseService } from 'common/services/CoreMouseService'; -import { MockCoreService, MockBufferService } from 'common/TestUtils.test'; +import { MockCoreService, MockBufferService, MockOptionsService } from 'common/TestUtils.test'; import { assert } from 'chai'; import { ICoreMouseEvent, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types'; // needed mock services const bufferService = new MockBufferService(300, 100); const coreService = new MockCoreService(); +const optionsService = new MockOptionsService(); function toBytes(s: string | undefined): number[] { if (!s) { @@ -24,20 +25,20 @@ function toBytes(s: string | undefined): number[] { describe('CoreMouseService', () => { it('init', () => { - const cms = new CoreMouseService(bufferService, coreService); + const cms = new CoreMouseService(bufferService, coreService, optionsService); assert.equal(cms.activeEncoding, 'DEFAULT'); assert.equal(cms.activeProtocol, 'NONE'); }); it('default protocols - NONE, X10, VT200, DRAG, ANY', () => { - const cms = new CoreMouseService(bufferService, coreService); + const cms = new CoreMouseService(bufferService, coreService, optionsService); assert.deepEqual(Object.keys((cms as any)._protocols), ['NONE', 'X10', 'VT200', 'DRAG', 'ANY']); }); it('default encodings - DEFAULT, SGR', () => { - const cms = new CoreMouseService(bufferService, coreService); + const cms = new CoreMouseService(bufferService, coreService, optionsService); assert.deepEqual(Object.keys((cms as any)._encodings), ['DEFAULT', 'SGR', 'SGR_PIXELS']); }); it('protocol/encoding setter, reset', () => { - const cms = new CoreMouseService(bufferService, coreService); + const cms = new CoreMouseService(bufferService, coreService, optionsService); cms.activeEncoding = 'SGR'; cms.activeProtocol = 'ANY'; assert.equal(cms.activeEncoding, 'SGR'); @@ -49,19 +50,19 @@ describe('CoreMouseService', () => { assert.throws(() => { cms.activeProtocol = 'xyz'; }, 'unknown protocol "xyz"'); }); it('addEncoding', () => { - const cms = new CoreMouseService(bufferService, coreService); + const cms = new CoreMouseService(bufferService, coreService, optionsService); cms.addEncoding('XYZ', (e: ICoreMouseEvent) => ''); cms.activeEncoding = 'XYZ'; assert.equal(cms.activeEncoding, 'XYZ'); }); it('addProtocol', () => { - const cms = new CoreMouseService(bufferService, coreService); + const cms = new CoreMouseService(bufferService, coreService, optionsService); cms.addProtocol('XYZ', { events: CoreMouseEventType.NONE, restrict: (e: ICoreMouseEvent) => false }); cms.activeProtocol = 'XYZ'; assert.equal(cms.activeProtocol, 'XYZ'); }); it('onProtocolChange', () => { - const cms = new CoreMouseService(bufferService, coreService); + const cms = new CoreMouseService(bufferService, coreService, optionsService); const wantedEvents: CoreMouseEventType[] = []; cms.onProtocolChange(events => wantedEvents.push(events)); cms.activeProtocol = 'NONE'; @@ -76,7 +77,7 @@ describe('CoreMouseService', () => { let cms: CoreMouseService; let reports: string[]; beforeEach(() => { - cms = new CoreMouseService(bufferService, coreService); + cms = new CoreMouseService(bufferService, coreService, optionsService); reports = []; coreService.triggerDataEvent = (data: string, userInput?: boolean) => reports.push(data); coreService.triggerBinaryEvent = (data: string) => reports.push(data);