From a053faeddaa6e54f2f9c15e84b64bbd175c68cef Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Wed, 15 May 2019 18:21:52 +0530 Subject: [PATCH] Typescript (Change title-bar from className to id ) (ELECTRON-748) (#647) * ELECTRON-748 - Change title-bar from className to id Fix linter issues * ELECTRON-748 - Fix unit tests cases --- config/titleBarStyles.css | 4 ++-- spec/__snapshots__/windowsTitleBar.spec.ts.snap | 2 +- spec/appCacheHandler.spec.ts | 9 +++++++++ spec/appMenu.spec.ts | 2 +- src/app/app-cache-handler.ts | 3 ++- src/app/child-window-handler.ts | 4 ++-- src/renderer/components/windows-title-bar.tsx | 2 +- src/renderer/styles/title-bar.less | 2 +- 8 files changed, 19 insertions(+), 9 deletions(-) diff --git a/config/titleBarStyles.css b/config/titleBarStyles.css index 2f483f25..b37db83b 100644 --- a/config/titleBarStyles.css +++ b/config/titleBarStyles.css @@ -12,7 +12,7 @@ Typically you'll want to set background-image: url(""); and background-size: cov ``` */ -.title-bar { +#title-bar { display: flex; position: fixed; background: rgba(74,74,74,1); @@ -150,4 +150,4 @@ Typically you'll want to set content: url("") and adjust the width property width: 100%; z-index: 3000; bottom: 0; -} \ No newline at end of file +} diff --git a/spec/__snapshots__/windowsTitleBar.spec.ts.snap b/spec/__snapshots__/windowsTitleBar.spec.ts.snap index 8b145afc..3655c6ec 100644 --- a/spec/__snapshots__/windowsTitleBar.spec.ts.snap +++ b/spec/__snapshots__/windowsTitleBar.spec.ts.snap @@ -2,7 +2,7 @@ exports[`windows title bar should render correctly 1`] = `
({ unlinkSync: jest.fn(), })); +jest.mock('../src/common/logger', () => { + return { + logger: { + error: jest.fn(), + info: jest.fn(), + }, + }; +}); + describe('app cache handler', () => { const cachePathExpected = path.join(app.getPath('userData'), 'CacheCheck'); diff --git a/spec/appMenu.spec.ts b/spec/appMenu.spec.ts index 564288eb..a1b37b12 100644 --- a/spec/appMenu.spec.ts +++ b/spec/appMenu.spec.ts @@ -121,7 +121,7 @@ describe('app menu', () => { describe('`popupMenu`', () => { it('should fail when `appMenu.menu` is null', () => { const spy = jest.spyOn(logger, 'error'); - const expectedValue = 'app-menu: tried popup menu, but failed menu not defined'; + const expectedValue = 'app-menu: tried popup menu, but failed, menu not defined'; appMenu.menu = null; appMenu.popupMenu(); expect(spy).toBeCalledWith(expectedValue); diff --git a/src/app/app-cache-handler.ts b/src/app/app-cache-handler.ts index 19c4939a..494996e0 100644 --- a/src/app/app-cache-handler.ts +++ b/src/app/app-cache-handler.ts @@ -1,7 +1,8 @@ import { app, session } from 'electron'; import * as fs from 'fs'; import * as path from 'path'; -import {logger} from "../common/logger"; + +import { logger } from '../common/logger'; // Cache check file path const cacheCheckFilePath: string = path.join(app.getPath('userData'), 'CacheCheck'); diff --git a/src/app/child-window-handler.ts b/src/app/child-window-handler.ts index f579a9c7..03424685 100644 --- a/src/app/child-window-handler.ts +++ b/src/app/child-window-handler.ts @@ -4,6 +4,7 @@ import { parse as parseQuerystring } from 'querystring'; import { format, parse, Url } from 'url'; import { isDevEnv, isWindowsOS } from '../common/env'; import { i18n } from '../common/i18n'; +import { logger } from '../common/logger'; import { getGuid } from '../common/utils'; import { config } from './config-handler'; import { monitorWindowActions, removeWindowEventListener } from './window-actions'; @@ -14,7 +15,6 @@ import { injectStyles, preventWindowNavigation, } from './window-utils'; -import {logger} from "../common/logger"; const DEFAULT_POP_OUT_WIDTH = 300; const DEFAULT_POP_OUT_HEIGHT = 600; @@ -183,7 +183,7 @@ export const handleChildWindow = (webContents: WebContents): void => { } }); } else { - logger.info(`child-window-handler: new window url is ${newWinUrl} which is not of the same host, + logger.info(`child-window-handler: new window url is ${newWinUrl} which is not of the same host, so opening it in the default browser!`); event.preventDefault(); windowHandler.openUrlInDefaultBrowser(newWinUrl); diff --git a/src/renderer/components/windows-title-bar.tsx b/src/renderer/components/windows-title-bar.tsx index 661b1b1c..acec1280 100644 --- a/src/renderer/components/windows-title-bar.tsx +++ b/src/renderer/components/windows-title-bar.tsx @@ -69,7 +69,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> { const style = { display: isFullScreen ? 'none' : 'flex' }; return ( -
diff --git a/src/renderer/styles/title-bar.less b/src/renderer/styles/title-bar.less index 007c0805..02478b84 100644 --- a/src/renderer/styles/title-bar.less +++ b/src/renderer/styles/title-bar.less @@ -4,7 +4,7 @@ @color_2: white; @background_color_1: rgba(51, 51, 51, 1); -.title-bar { +#title-bar { display: flex; position: fixed; background: rgba(74, 74, 74, 1);