Skip to content

Commit 9b21f19

Browse files
authored
fix: allow connexion to MSFS (#9)
1 parent c5deff2 commit 9b21f19

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/api.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ export class FsuipcApi {
1313
private fsuipc: FSUIPC;
1414
private watchedOffsetCache: any[] = [];
1515

16-
constructor(private simulator: Simulator = Simulator.FSX) {}
16+
constructor(private simulator?: Simulator) {}
1717

1818
public async init() {
1919
this.fsuipcGlobalInstance = new FSUIPC();
2020

2121
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+
}
2327
return true;
2428
} catch (error) {
2529
throw new FSUIPCError(error.message, error.code);

tests/api.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ jest.mock('fsuipc', () => {
3737
return {
3838
FSUIPC: jest.fn().mockImplementation(() => {
3939
return {
40-
open: jest.fn().mockImplementation((simulator) => {
41-
if (simulator === SimulatorMock.FSX) {
40+
open: jest.fn().mockImplementation((simulator?) => {
41+
if (simulator !== SimulatorMock.P3D64) {
4242
return Promise.resolve({
4343
process: processMock,
4444
add: addMock,
@@ -163,9 +163,9 @@ describe('FSUIPC Api', () => {
163163
expect(instance['simulator']).toEqual(SimulatorMock.P3D64);
164164
});
165165

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', () => {
167167
const instance = new FsuipcApi();
168-
expect(instance['simulator']).toEqual(SimulatorMock.FSX);
168+
expect(instance['simulator']).toEqual(undefined);
169169
});
170170
});
171171

0 commit comments

Comments
 (0)