Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
feat: added support to query for arm arch from ng
Browse files Browse the repository at this point in the history
  • Loading branch information
Sören Hanisch authored and Sören Hanisch committed Aug 13, 2019
1 parent 500803b commit 7be70a0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions projects/ngx-electron/src/lib/electron.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export class ElectronService {
return this.isElectronApp && process.arch === 'x64';
}

public get isArm(): boolean {
return this.isElectronApp && process.arch === 'arm';
}

public get desktopCapturer(): Electron.DesktopCapturer {
return this.electron ? this.electron.desktopCapturer : null;
}
Expand Down
38 changes: 38 additions & 0 deletions projects/ngx-electron/tests/electron.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,44 @@ describe('ElectronService', () => {

});

describe('isArm', () => {

it('should provide isArm as an instance-property', () => {
expect(_electronService).hasOwnProperty('isArm');
});

it('should return a boolean', () => {
expect(typeof _electronService.isArm).toEqual('boolean');
});


it('should return false if isElectronApp is false', () => {
expect(_electronService.isArm).toBeFalsy();
});

it('should return true if running in electron with arm arch', () => {
let originalArch = process.arch;
let originalUserAgent = navigator.userAgent;
(<any>navigator).__defineGetter__('userAgent', (): string => {
return 'foo Electron';
});
(<any>process).__defineGetter__('arch', (): string => {
return 'arm';
});

expect(_electronService.isArm).toBeTruthy();

(<any>process).__defineGetter__('arch', (): string => {
return originalArch;
});

(<any>navigator).__defineGetter__('userAgent', (): string => {
return originalUserAgent;
});
});

});

describe('api', () => {

it('should expose desktopCapturer', () => {
Expand Down

0 comments on commit 7be70a0

Please sign in to comment.