Fix OS desktop detection tests and edge cases
- Fix test cases not running for desktop OS detection. - Fixes application throwing error when user agent is undefined. - Refactor by making os property optional in Environment to explicit describe its potential undefined state.
This commit is contained in:
@@ -24,9 +24,12 @@ export class Environment implements IEnvironment {
|
||||
throw new Error('variables is null or empty');
|
||||
}
|
||||
this.isDesktop = isDesktop(variables);
|
||||
this.os = this.isDesktop ?
|
||||
getDesktopOsType(getProcessPlatform(variables))
|
||||
: browserOsDetector.detect(getUserAgent(variables));
|
||||
if (this.isDesktop) {
|
||||
this.os = getDesktopOsType(getProcessPlatform(variables));
|
||||
} else {
|
||||
const userAgent = getUserAgent(variables);
|
||||
this.os = !userAgent ? undefined : browserOsDetector.detect(userAgent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user