restore opr and safari on window

This commit is contained in:
Kyle Spearrin 2018-04-14 11:54:59 -04:00
parent 5510f1b560
commit 4993d4b00d
1 changed files with 15 additions and 2 deletions

View File

@ -33,12 +33,20 @@ describe('Browser Utils Service', () => {
});
describe('getBrowser', () => {
const original = navigator.userAgent;
const originalUserAgent = navigator.userAgent;
const originalSafari = (window as any).safari;
const originalOpr = (window as any).opr;
// Reset the userAgent.
afterAll(() => {
Object.defineProperty(navigator, 'userAgent', {
value: original
value: originalUserAgent
});
Object.defineProperty(window, 'safari', {
value: originalSafari
});
Object.defineProperty(window, 'opr', {
value: originalOpr
});
});
@ -67,6 +75,11 @@ describe('Browser Utils Service', () => {
configurable: true,
value: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3175.3 Safari/537.36 OPR/49.0.2695.0 (Edition developer)'
});
Object.defineProperty(window, 'opr', {
configurable: true,
value: {}
});
const browserPlatformUtilsService = new BrowserPlatformUtilsService(null);
expect(browserPlatformUtilsService.getDevice()).toBe(DeviceType.Opera);