File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,17 @@ export class FsuipcApi {
13
13
private fsuipc : FSUIPC ;
14
14
private watchedOffsetCache : any [ ] = [ ] ;
15
15
16
- constructor ( private simulator : Simulator = Simulator . FSX ) { }
16
+ constructor ( private simulator ? : Simulator ) { }
17
17
18
18
public async init ( ) {
19
19
this . fsuipcGlobalInstance = new FSUIPC ( ) ;
20
20
21
21
try {
22
- this . fsuipc = await this . fsuipcGlobalInstance . open ( this . simulator ) ;
22
+ if ( this . simulator ) {
23
+ this . fsuipc = await this . fsuipcGlobalInstance . open ( this . simulator ) ;
24
+ } else {
25
+ this . fsuipc = await this . fsuipcGlobalInstance . open ( ) ;
26
+ }
23
27
return true ;
24
28
} catch ( error ) {
25
29
throw new FSUIPCError ( error . message , error . code ) ;
Original file line number Diff line number Diff line change @@ -37,8 +37,8 @@ jest.mock('fsuipc', () => {
37
37
return {
38
38
FSUIPC : jest . fn ( ) . mockImplementation ( ( ) => {
39
39
return {
40
- open : jest . fn ( ) . mockImplementation ( ( simulator ) => {
41
- if ( simulator === SimulatorMock . FSX ) {
40
+ open : jest . fn ( ) . mockImplementation ( ( simulator ? ) => {
41
+ if ( simulator !== SimulatorMock . P3D64 ) {
42
42
return Promise . resolve ( {
43
43
process : processMock ,
44
44
add : addMock ,
@@ -163,9 +163,9 @@ describe('FSUIPC Api', () => {
163
163
expect ( instance [ 'simulator' ] ) . toEqual ( SimulatorMock . P3D64 ) ;
164
164
} ) ;
165
165
166
- it ( 'should create instance with FSX by default when no simulator provided' , ( ) => {
166
+ it ( 'should create instance with any Simulator by default when no simulator provided' , ( ) => {
167
167
const instance = new FsuipcApi ( ) ;
168
- expect ( instance [ 'simulator' ] ) . toEqual ( SimulatorMock . FSX ) ;
168
+ expect ( instance [ 'simulator' ] ) . toEqual ( undefined ) ;
169
169
} ) ;
170
170
} ) ;
171
171
You can’t perform that action at this time.
0 commit comments