Skip to content

Commit

Permalink
cleaned up comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrohmer committed Sep 26, 2024
1 parent 1ca90e5 commit 8d89f5d
Show file tree
Hide file tree
Showing 272 changed files with 801 additions and 2,704 deletions.
9 changes: 0 additions & 9 deletions src/__tests__/main/controllers/IncrementController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ describe('IncrementController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle get-all-increments correctly', async () => {
Expand Down Expand Up @@ -189,7 +188,6 @@ describe('IncrementController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle get-all-increments with default sortby', async () => {
Expand Down Expand Up @@ -251,7 +249,6 @@ describe('IncrementController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle get-increment-by-id nulled', async () => {
Expand All @@ -264,7 +261,6 @@ describe('IncrementController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle get-latest-increment correctly', async () => {
Expand Down Expand Up @@ -298,7 +294,6 @@ describe('IncrementController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle get-latest-increment nulled', async () => {
Expand All @@ -310,7 +305,6 @@ describe('IncrementController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle update-increment correctly', async () => {
Expand Down Expand Up @@ -346,7 +340,6 @@ describe('IncrementController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle update-increment nulled', async () => {
Expand All @@ -359,7 +352,6 @@ describe('IncrementController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle delete-increment correctly', async () => {
Expand All @@ -380,6 +372,5 @@ describe('IncrementController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});
});
7 changes: 0 additions & 7 deletions src/__tests__/main/controllers/ModelController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ describe('ModelController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle get-all-models correctly', async () => {
Expand Down Expand Up @@ -188,7 +187,6 @@ describe('ModelController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle get-model-by-id correctly', async () => {
Expand Down Expand Up @@ -222,7 +220,6 @@ describe('ModelController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle get-model-by-id nulled', async () => {
Expand All @@ -235,7 +232,6 @@ describe('ModelController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle update-model correctly', async () => {
Expand Down Expand Up @@ -271,7 +267,6 @@ describe('ModelController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle update-model nulled', async () => {
Expand All @@ -284,7 +279,6 @@ describe('ModelController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle delete-model correctly', async () => {
Expand All @@ -305,6 +299,5 @@ describe('ModelController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});
});
7 changes: 0 additions & 7 deletions src/__tests__/main/controllers/ProductController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ describe('ProductController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle get-product-by-id correctly', async () => {
Expand Down Expand Up @@ -224,7 +223,6 @@ describe('ProductController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle get-product-by-id nulled', async () => {
Expand All @@ -237,7 +235,6 @@ describe('ProductController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle create-product correctly', async () => {
Expand Down Expand Up @@ -280,7 +277,6 @@ describe('ProductController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle update-product correctly', async () => {
Expand Down Expand Up @@ -329,7 +325,6 @@ describe('ProductController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle update-product nulled', async () => {
Expand All @@ -347,7 +342,6 @@ describe('ProductController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});

it('should handle delete-product correctly', async () => {
Expand All @@ -368,6 +362,5 @@ describe('ProductController', () => {
});

expect(response).toBeUndefined();
// expect(console.error).toHaveBeenCalledWith(error); // Uncomment if you want to check console.error call
});
});
5 changes: 0 additions & 5 deletions src/__tests__/main/controllers/VersionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ describe('VersionController', () => {
new Error('Model not found'),
);

// const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();

const response = await ipcRenderer.invoke('create-version', {
modelId: null,
payload: { graph: { graph: {} } },
Expand Down Expand Up @@ -176,8 +174,6 @@ describe('VersionController', () => {
const error = new Error('Fetch error');
versionService.getAllVersions.mockRejectedValue(error);

// const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();

const response = await ipcRenderer.invoke('get-all-versions', {
sort: 'asc',
sortby: 'createdAt',
Expand Down Expand Up @@ -275,7 +271,6 @@ describe('VersionController', () => {

it('should handle get-latest-version by model ID with nulled modelId', async () => {
const error = new Error('No modelId provided');
// versionService.getLatestVersionByModelId.mockResolvedValue(null);

const response = await ipcRenderer.invoke('get-latest-version', {
modelId: null,
Expand Down
8 changes: 2 additions & 6 deletions src/__tests__/main/helpers/entityBuilder.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// __tests__/entityBuilder.test.ts
import { buildProductEntity } from '../../../main/helpers/entityBuilder';
import { Product } from '../../../main/models/Product';
import { Responsible } from '../../../main/models/Responsible';
import { Increment } from '../../../main/models/Increment';
import { Model } from '../../../main/models/Model';
import { Version } from '../../../main/models/Version';

// Mock the model classes to avoid importing TypeORM and database dependencies
jest.mock('../../../main/models/Product');
jest.mock('../../../main/models/Responsible');
jest.mock('../../../main/models/Increment');
Expand Down Expand Up @@ -182,13 +180,11 @@ describe('buildProductEntity', () => {

it('should truncate the product name to fit within 250 characters including the baseline suffix', () => {
const productData = new Product();
// Create a name that is 240 characters long
productData.name = 'A'.repeat(240); // 240 characters
productData.name = 'A'.repeat(240);
productData.startsAt = new Date('2024-01-01T00:00:00.000Z');

const product = buildProductEntity(productData);

// The name should be 240 characters + " - Baseline" (11 characters) = 251 characters total
expect(product.increments[0].name).toBe(`${'A'.repeat(239)} - Baseline`); // Truncated to fit 250 characters total
expect(product.increments[0].name).toBe(`${'A'.repeat(239)} - Baseline`);
});
});
6 changes: 3 additions & 3 deletions src/__tests__/main/helpers/isDataUriPng.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { validate } from 'class-validator';
import { IsDataUriPng } from '../../../main/helpers/isDataUriPng'; // Adjust the path accordingly
import { IsDataUriPng } from '../../../main/helpers/isDataUriPng';

class TestDto {
@IsDataUriPng()
Expand All @@ -9,9 +9,9 @@ class TestDto {
describe('IsDataUriPng', () => {
it('should validate a valid PNG Data URI', async () => {
const dto = new TestDto();
dto.thumbnail = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA'; // Valid PNG Data URI
dto.thumbnail = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA';

const errors = await validate(dto);
expect(errors.length).toBe(0); // Expect no validation errors
expect(errors.length).toBe(0);
});
});
4 changes: 2 additions & 2 deletions src/__tests__/main/helpers/isJsonString.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class TestDto {
describe('IsJsonString', () => {
it('should validate a valid stringified JSON', async () => {
const dto = new TestDto();
dto.payload = JSON.stringify({ key: 'value' }); // Valid JSON
dto.payload = JSON.stringify({ key: 'value' });

const errors = await validate(dto);
expect(errors.length).toBe(0); // Expect no validation errors
expect(errors.length).toBe(0);
});
});
17 changes: 2 additions & 15 deletions src/__tests__/main/menu.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ describe('MenuBuilder', () => {
(item) => item.label === 'Toggle Full Screen',
);

// Simulate the mainWindow being in full screen
(mainWindow.isFullScreen as jest.Mock).mockReturnValue(true);
toggleFullScreenItem.click();
expect(mainWindow.setFullScreen).toHaveBeenCalledWith(false);
Expand All @@ -160,7 +159,6 @@ describe('MenuBuilder', () => {
(item) => item.label === 'Toggle Full Screen',
);

// Simulate the mainWindow being in full screen
(mainWindow.isFullScreen as jest.Mock).mockReturnValue(true);
toggleFullScreenItem.click();
expect(mainWindow.setFullScreen).toHaveBeenCalledWith(false);
Expand Down Expand Up @@ -235,7 +233,6 @@ describe('MenuBuilder', () => {
(item) => item.label === 'Toggle &Full Screen',
);

// Simulate the mainWindow being in full screen
(mainWindow.isFullScreen as jest.Mock).mockReturnValue(true);
toggleFullScreenItem.click();
expect(mainWindow.setFullScreen).toHaveBeenCalledWith(false);
Expand All @@ -250,15 +247,12 @@ describe('MenuBuilder', () => {
(item) => item.label === 'Toggle &Full Screen',
);

// Ensure toggleFullScreenItem is defined before accessing its click property
expect(toggleFullScreenItem).toBeDefined();

// Simulate the mainWindow initially not being in full screen
(mainWindow.isFullScreen as jest.Mock).mockReturnValue(false);
toggleFullScreenItem.click();
expect(mainWindow.setFullScreen).toHaveBeenCalledWith(true);

// Simulate the mainWindow being in full screen
(mainWindow.isFullScreen as jest.Mock).mockReturnValue(true);
toggleFullScreenItem.click();
expect(mainWindow.setFullScreen).toHaveBeenCalledWith(false);
Expand Down Expand Up @@ -412,7 +406,6 @@ describe('MenuBuilder', () => {
(item) => item.label === 'Toggle &Full Screen',
);

// Simulate the mainWindow initially not being in full screen
(mainWindow.isFullScreen as jest.Mock).mockReturnValue(false);
toggleFullScreenItem.click();
expect(mainWindow.setFullScreen).toHaveBeenCalledWith(true);
Expand All @@ -427,15 +420,12 @@ describe('MenuBuilder', () => {
(item) => item.label === 'Toggle &Full Screen',
);

// Ensure toggleFullScreenItem is defined before accessing its click property
expect(toggleFullScreenItem).toBeDefined();

// Simulate the mainWindow initially not being in full screen
(mainWindow.isFullScreen as jest.Mock).mockReturnValue(false);
toggleFullScreenItem.click();
expect(mainWindow.setFullScreen).toHaveBeenCalledWith(true);

// Simulate the mainWindow being in full screen
(mainWindow.isFullScreen as jest.Mock).mockReturnValue(true);
toggleFullScreenItem.click();
expect(mainWindow.setFullScreen).toHaveBeenCalledWith(false);
Expand All @@ -450,15 +440,12 @@ describe('MenuBuilder', () => {
(item) => item.label === 'Toggle &Full Screen',
);

// Ensure toggleFullScreenItem is defined before accessing its click property
expect(toggleFullScreenItem).toBeDefined();

// Simulate the mainWindow initially not being in full screen
(mainWindow.isFullScreen as jest.Mock).mockReturnValue(false);
toggleFullScreenItem.click();
expect(mainWindow.setFullScreen).toHaveBeenCalledWith(true);

// Simulate the mainWindow being in full screen
(mainWindow.isFullScreen as jest.Mock).mockReturnValue(true);
toggleFullScreenItem.click();
expect(mainWindow.setFullScreen).toHaveBeenCalledWith(false);
Expand All @@ -469,7 +456,7 @@ describe('MenuBuilder', () => {
value: 'darwin',
});

process.env.NODE_ENV = 'production'; // Ensure environment is production for consistent template
process.env.NODE_ENV = 'production';

const menu = menuBuilder.buildMenu();

Expand All @@ -483,7 +470,7 @@ describe('MenuBuilder', () => {
value: 'win32',
});

process.env.NODE_ENV = 'development'; // Ensure environment is development for consistent template
process.env.NODE_ENV = 'development';

const menu = menuBuilder.buildMenu();

Expand Down
Loading

0 comments on commit 8d89f5d

Please sign in to comment.