@@ -7,7 +7,6 @@ import { CompositeLogger } from "../../../src/common/logger.js";
77// Mock the dependencies
88vi . mock ( "@mongodb-js/device-id" ) ;
99vi . mock ( "node-machine-id" ) ;
10-
1110const MockGetDeviceId = vi . mocked ( getDeviceId ) ;
1211
1312describe ( "Device ID Helper" , ( ) => {
@@ -18,9 +17,6 @@ describe("Device ID Helper", () => {
1817 vi . clearAllMocks ( ) ;
1918 testLogger = new CompositeLogger ( ) ;
2019
21- // Create a mock getMachineId function
22- mockGetMachineId = vi . fn ( ) . mockResolvedValue ( "test-machine-id" ) ;
23-
2420 // Reset singleton between tests
2521 DeviceIdService . resetInstance ( ) ;
2622 } ) ;
@@ -33,7 +29,7 @@ describe("Device ID Helper", () => {
3329 describe ( "DeviceIdService Singleton" , ( ) => {
3430 it ( "should return the same instance for multiple getInstance calls" , ( ) => {
3531 // Initialize first
36- DeviceIdService . init ( testLogger , mockGetMachineId ) ;
32+ DeviceIdService . init ( testLogger ) ;
3733
3834 const instance1 = DeviceIdService . getInstance ( ) ;
3935 const instance2 = DeviceIdService . getInstance ( ) ;
@@ -50,25 +46,20 @@ describe("Device ID Helper", () => {
5046 MockGetDeviceId . mockResolvedValue ( mockDeviceId ) ;
5147
5248 // Initialize after mocking
53- DeviceIdService . init ( testLogger , mockGetMachineId ) ;
49+ DeviceIdService . init ( testLogger ) ;
5450
5551 const deviceId = DeviceIdService . getInstance ( ) ;
5652 const result = await deviceId . getDeviceId ( ) ;
5753
5854 expect ( result ) . toBe ( mockDeviceId ) ;
59- expect ( MockGetDeviceId ) . toHaveBeenCalledWith ( {
60- getMachineId : mockGetMachineId ,
61- onError : expect . any ( Function ) ,
62- abortSignal : expect . any ( AbortSignal ) ,
63- } ) ;
6455 } ) ;
6556
6657 it ( "should cache device ID after first retrieval" , async ( ) => {
6758 const mockDeviceId = "test-device-id-123" ;
6859 MockGetDeviceId . mockResolvedValue ( mockDeviceId ) ;
6960
7061 // Initialize after mocking
71- DeviceIdService . init ( testLogger , mockGetMachineId ) ;
62+ DeviceIdService . init ( testLogger ) ;
7263
7364 const deviceId = DeviceIdService . getInstance ( ) ;
7465
@@ -88,7 +79,7 @@ describe("Device ID Helper", () => {
8879 MockGetDeviceId . mockResolvedValue ( mockDeviceId ) ;
8980
9081 // Initialize after mocking
91- DeviceIdService . init ( testLogger , mockGetMachineId ) ;
82+ DeviceIdService . init ( testLogger ) ;
9283
9384 const deviceId = DeviceIdService . getInstance ( ) ;
9485
@@ -115,7 +106,7 @@ describe("Device ID Helper", () => {
115106 } ) ;
116107
117108 // Initialize after mocking
118- DeviceIdService . init ( testLogger , mockGetMachineId ) ;
109+ DeviceIdService . init ( testLogger ) ;
119110
120111 const deviceId = DeviceIdService . getInstance ( ) ;
121112
@@ -133,7 +124,7 @@ describe("Device ID Helper", () => {
133124 MockGetDeviceId . mockRejectedValue ( new Error ( "Device ID resolution failed" ) ) ;
134125
135126 // Initialize after mocking
136- DeviceIdService . init ( testLogger , mockGetMachineId ) ;
127+ DeviceIdService . init ( testLogger ) ;
137128
138129 const deviceId = DeviceIdService . getInstance ( ) ;
139130 const result = await deviceId . getDeviceId ( ) ;
@@ -150,7 +141,7 @@ describe("Device ID Helper", () => {
150141 } ) ;
151142
152143 // Initialize after mocking
153- DeviceIdService . init ( testLogger , mockGetMachineId ) ;
144+ DeviceIdService . init ( testLogger ) ;
154145
155146 const deviceId = DeviceIdService . getInstance ( ) ;
156147 const result = await deviceId . getDeviceId ( ) ;
@@ -167,7 +158,7 @@ describe("Device ID Helper", () => {
167158 } ) ;
168159
169160 // Initialize after mocking
170- DeviceIdService . init ( testLogger , mockGetMachineId ) ;
161+ DeviceIdService . init ( testLogger ) ;
171162
172163 const deviceId = DeviceIdService . getInstance ( ) ;
173164 const result = await deviceId . getDeviceId ( ) ;
@@ -184,7 +175,7 @@ describe("Device ID Helper", () => {
184175 } ) ;
185176
186177 // Initialize after mocking
187- DeviceIdService . init ( testLogger , mockGetMachineId ) ;
178+ DeviceIdService . init ( testLogger ) ;
188179
189180 const deviceId = DeviceIdService . getInstance ( ) ;
190181 const result = await deviceId . getDeviceId ( ) ;
@@ -199,7 +190,7 @@ describe("Device ID Helper", () => {
199190 MockGetDeviceId . mockRejectedValue ( new Error ( "Device ID failed" ) ) ;
200191
201192 // Initialize after mocking
202- DeviceIdService . init ( testLogger , mockGetMachineId ) ;
193+ DeviceIdService . init ( testLogger ) ;
203194
204195 const deviceId = DeviceIdService . getInstance ( ) ;
205196 const result = await deviceId . getDeviceId ( ) ;
@@ -211,7 +202,7 @@ describe("Device ID Helper", () => {
211202 MockGetDeviceId . mockResolvedValue ( "device-id" ) ;
212203
213204 // Initialize after mocking
214- DeviceIdService . init ( testLogger , mockGetMachineId ) ;
205+ DeviceIdService . init ( testLogger ) ;
215206
216207 const deviceId = DeviceIdService . getInstance ( ) ;
217208 await deviceId . getDeviceId ( ) ;
@@ -226,7 +217,7 @@ describe("Device ID Helper", () => {
226217 MockGetDeviceId . mockRejectedValue ( "String error" ) ;
227218
228219 // Initialize after mocking
229- DeviceIdService . init ( testLogger , mockGetMachineId ) ;
220+ DeviceIdService . init ( testLogger ) ;
230221
231222 const deviceId = DeviceIdService . getInstance ( ) ;
232223 const result = await deviceId . getDeviceId ( ) ;
0 commit comments