Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobgoerke committed Sep 23, 2024
1 parent 599714b commit 51f6f2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
12 changes: 2 additions & 10 deletions src/AcInfinityClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface GetDeviceParams {
port: number;
}

class AcInfinityClientInstance {
class AcInfinityClient {
constructor(args: AuthParams) {
const { email, password } = args;

Expand Down Expand Up @@ -99,17 +99,9 @@ class AcInfinityClientInstance {

return DeviceModeSettingsSchema.parse(response.data.data);
}
}

class AcInfinityClient {
constructor(args: AuthParams) {
this.instance = new AcInfinityClientInstance(args);
}

public instance: AcInfinityClientInstance;

static async build(args: AuthParams) {
const instance = new AcInfinityClientInstance(args);
const instance = new AcInfinityClient(args);
await instance.authenticate();
return instance;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/AcInfinityClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('AcInfintyClient', () => {
const client = new AcInfinityClient(authparams);

// then
expect(client.instance.authenticate()).rejects.toThrow(AuthenticationError);
expect(client.authenticate()).rejects.toThrow(AuthenticationError);
});

it('should throw ZodError when invalid data is returned', async () => {
Expand All @@ -65,7 +65,7 @@ describe('AcInfintyClient', () => {
const client = new AcInfinityClient(authparams);

// when
const controllers = await client.instance.getControllers();
const controllers = await client.getControllers();

// then
expect(mockAxios.post).toHaveBeenCalledWith(Url.CONTROLLERS, { userId: '' });
Expand All @@ -80,7 +80,7 @@ describe('AcInfintyClient', () => {
const client = new AcInfinityClient(authparams);

// when
await client.instance.getDeviceSettings({ deviceId: 'test', port: 1 });
await client.getDeviceSettings({ deviceId: 'test', port: 1 });

// then
expect(mockAxios.post).toHaveBeenCalledWith(Url.DEVICE_SETTINGS, { devId: 'test', port: 1 });
Expand All @@ -94,7 +94,7 @@ describe('AcInfintyClient', () => {
const client = new AcInfinityClient(authparams);

// when
await client.instance.getDeviceModeSettings({ deviceId: 'test', port: 1 });
await client.getDeviceModeSettings({ deviceId: 'test', port: 1 });

// then
expect(mockAxios.post).toHaveBeenCalledWith(Url.DEVICE_MODE_SETTINGS, { devId: 'test', port: 1 });
Expand Down

0 comments on commit 51f6f2d

Please sign in to comment.