[MM-40330] Unit tests for main/windows (#1885)

* [MM-40330] Unit tests for main/windows

* Merge'd
This commit is contained in:
Devin Binnie
2021-12-06 11:08:39 -05:00
committed by GitHub
parent 72f7cb4f08
commit 4a98dce51e
21 changed files with 1698 additions and 535 deletions

View File

@@ -6,7 +6,7 @@ import {app} from 'electron';
import * as Badge from './badge';
import {setOverlayIcon} from './windows/windowManager';
import WindowManager from './windows/windowManager';
jest.mock('electron', () => ({
app: {
@@ -28,28 +28,28 @@ describe('main/badge', () => {
describe('showBadgeWindows', () => {
it('should show dot when session expired', () => {
Badge.showBadgeWindows(true, 7, false);
expect(setOverlayIcon).toBeCalledWith('•', expect.any(String), expect.any(Boolean));
expect(WindowManager.setOverlayIcon).toBeCalledWith('•', expect.any(String), expect.any(Boolean));
});
it('should show mention count when has mention count', () => {
Badge.showBadgeWindows(false, 50, false);
expect(setOverlayIcon).toBeCalledWith('50', expect.any(String), false);
expect(WindowManager.setOverlayIcon).toBeCalledWith('50', expect.any(String), false);
});
it('should show 99+ when has mention count over 99', () => {
Badge.showBadgeWindows(false, 200, false);
expect(setOverlayIcon).toBeCalledWith('99+', expect.any(String), true);
expect(WindowManager.setOverlayIcon).toBeCalledWith('99+', expect.any(String), true);
});
it('should not show dot when has unreads but setting is off', () => {
Badge.showBadgeWindows(false, 0, true);
expect(setOverlayIcon).not.toBeCalledWith('•', expect.any(String), expect.any(Boolean));
expect(WindowManager.setOverlayIcon).not.toBeCalledWith('•', expect.any(String), expect.any(Boolean));
});
it('should show dot when has unreads', () => {
Badge.setUnreadBadgeSetting(true);
Badge.showBadgeWindows(false, 0, true);
expect(setOverlayIcon).toBeCalledWith('•', expect.any(String), expect.any(Boolean));
expect(WindowManager.setOverlayIcon).toBeCalledWith('•', expect.any(String), expect.any(Boolean));
Badge.setUnreadBadgeSetting(false);
});
});