Skip to content

Commit

Permalink
Refactor project (#65)
Browse files Browse the repository at this point in the history
* refactor(): Remove unused import

* refactor(): test folder name refactoring
  • Loading branch information
onemanfighter authored Jun 21, 2024
1 parent e34bd83 commit c121db3
Show file tree
Hide file tree
Showing 72 changed files with 27 additions and 81 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"react/react-in-jsx-scope": "off",
"no-unused-vars": "off",
"no-undef": "off",
"no-console": "off",
"no-console": "warn",
"no-empty": "off",
"no-useless-escape": "off",
"@typescript-eslint/no-empty-interface": "off",
Expand All @@ -31,7 +31,7 @@
"no-irregular-whitespace": "off",
"react/no-children-prop": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-var-requires": "off"
Expand Down
2 changes: 1 addition & 1 deletion src/assets/mac/Mac.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { memo } from 'react';
import React from 'react';
import { MAC_SVG } from './constants';

const MacIcon = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render, screen } from '@testing-library/react';
import { render } from '@testing-library/react';
import { Menu } from '@chakra-ui/react';
import { SearchIcon } from '@assets';
import MenuListComponent from '../MenuListComponent';

describe('MenuList component', () => {
Expand Down
3 changes: 0 additions & 3 deletions src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Modal, ModalContent, ModalOverlay } from '@chakra-ui/react';
import { ModalProps } from './types';
import { useTranslation } from 'react-i18next';
import { SearchModal } from './Modals';
import { ModalID } from '@uiStore';

Expand All @@ -14,8 +13,6 @@ const ModalToShow = ({ modalID }: { modalID: ModalID }) => {
};

const ModalComponent = ({ isOpen, modalID, onModalClose }: ModalProps) => {
const { t } = useTranslation();

return (
<Modal isOpen={isOpen} onClose={onModalClose}>
<ModalOverlay />
Expand Down
2 changes: 1 addition & 1 deletion src/components/TopBarButton/TopBarButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, MenuButton, Text } from '@chakra-ui/react';
import { MenuButton, Text } from '@chakra-ui/react';
import { TopBarButtonProps } from './types';
import {
darkModeColorSelector,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Window/__tests__/WindowControl.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('WindowControl', () => {
});

it('should trigger maximize on maximize button press', () => {
const { container } = render(
render(
<WindowControl
app={ProgramType.FINDER}
onMaximizeClick={maximizeClickHandler}
Expand Down
1 change: 0 additions & 1 deletion src/components/Window/__tests__/Windows.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { fireEvent, render, screen } from '@testing-library/react';
import Window from '../Window';
import exp from 'constants';
import { ProgramType } from '@processStore';

describe('Windows', () => {
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useWindowDimension.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect, useState } from 'react';

const getWindowDimensions = () => {
const { noOfProgram } = { noOfProgram: 1 };
const { innerWidth: width, innerHeight: height } = window;
return {
width: width,
Expand Down
7 changes: 1 addition & 6 deletions src/providers/modal/ModalProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { useCallback, useEffect } from 'react';
import { useDisclosure } from '@chakra-ui/react';
import { ModalComponent } from '@components';
import {
ModalOpenState,
uiStore,
modalDataSelector,
useShallow,
} from '@uiStore';
import { ModalOpenState, uiStore, modalDataSelector } from '@uiStore';

import { ModalProviderProps } from './types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render, renderHook, screen, waitFor } from '@testing-library/react';
import { LazyPowerComponent } from '../LazyPowerScreen';
import { cleanup } from '@testing-library/react-hooks';
import { processStore } from '@processStore';

describe('LazyPowerComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { renderHook } from '@testing-library/react-hooks';

describe('LazyPoweringComponent', () => {
it('should render correctly to match snapshot', async () => {
const { result } = renderHook(() => uiStore());
renderHook(() => uiStore());
const { container } = render(<LazyPoweringComponent />);

await waitFor(() =>
Expand Down
3 changes: 1 addition & 2 deletions src/router/routes/private/__tests__/PrivateRoutes.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render, renderHook } from '@testing-library/react';
import { renderHook } from '@testing-library/react';
import { privateRouter } from '../PrivateRoutes';
import { BrowserRouter, RouterProvider } from 'react-router-dom';

describe('PrivateRoutes', () => {
it('should render the PrivateRoutes component', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/router/routes/public/__tests__/PublicRoutes.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render, renderHook } from '@testing-library/react';
import { renderHook } from '@testing-library/react';

import { BrowserRouter, RouterProvider } from 'react-router-dom';
import { publicRouterPower, publicRouterPowering } from '../PublicRoutes';

describe('Public router', () => {
Expand Down
1 change: 0 additions & 1 deletion src/screens/private/Home/BottomBar/BottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const BottomBar = (_props: BottomBarProps) => {
...activeAppRunningSelector(state),
})),
);
console.log(allActiveApps);

const runningMiddleApps = getAllAppOtherThanBottomBarApps(
allActiveApps as ProgramType[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('BottomBar', () => {

it('should render invoke onclick on launch pad click', async () => {
const setLaunchpad = jest.fn();
const { result } = renderHook(() => processStore());
renderHook(() => processStore());
render(
<LaunchpadContext.Provider value={{ launchpad: false, setLaunchpad }}>
<BottomBar />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Program button', () => {
});

it('should invoke click handler on program button press', () => {
const { container } = render(
render(
<DragDropContext onDragEnd={jest.fn()}>
<Droppable droppableId="list" direction="horizontal">
{() => (
Expand Down
1 change: 0 additions & 1 deletion src/screens/private/Home/BottomBar/components/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Terminal from '../../../../../assets/logo/terminal.png';
import Spotify from '../../../../../assets/logo/spotify.png';
import Github from '../../../../../assets/logo/github.png';
import Settings from '../../../../../assets/logo/settings.png';
import Bin from '../../../../../assets/logo/bin.png';
import Notes from '../../../../../assets/logo/notes.png';
import Launchpad from '../../../../../assets/logo/launchpad.png';

Expand Down
3 changes: 1 addition & 2 deletions src/screens/private/Home/BottomBar/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { AppState, ProgramType } from '@processStore';
import { ProgramType } from '@processStore';
import { ProgramItem } from './type';
import { BottomBarProgramType } from './components';

export const reorder = (
list: ProgramItem[],
Expand Down
7 changes: 1 addition & 6 deletions src/screens/private/Home/TopBar/LeftSideComponents/Apple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import {
MenuListComponent,
TopBarButton,
} from '@components';
import {
activeAppActionsSelector,
loginSelector,
powerSelector,
processStore,
} from '@processStore';
import { loginSelector, powerSelector, processStore } from '@processStore';
import {
darkModeColorSelector,
settingsStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,15 @@ describe('MenuBranch', () => {
});

it('should trigger item action on clicking with normal type', () => {
const { container } = render(
<MenuBranch title={'Test'} type={'normal'} items={dummyData} />,
);
render(<MenuBranch title={'Test'} type={'normal'} items={dummyData} />);

fireEvent.click(screen.getByLabelText('test-1-menu-button'));

expect(actionMockTest1).toHaveBeenCalledTimes(1);
});

it('should trigger item action when inner menu is clicked with normal type', () => {
const { container } = render(
<MenuBranch title={'Test'} type={'normal'} items={dummyData} />,
);
render(<MenuBranch title={'Test'} type={'normal'} items={dummyData} />);

fireEvent.click(screen.getByLabelText('sub-tree-test-1-sub-menu-item'));

Expand Down
11 changes: 2 additions & 9 deletions src/screens/private/Home/TopBar/RightSideComponents/Battery.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { BatteryIcon, MacIcon, SearchIcon } from '@assets';
import {
Box,
Menu,
MenuDivider,
MenuItem,
MenuList,
Text,
} from '@chakra-ui/react';
import { BatteryIcon } from '@assets';
import { Box, Menu, MenuDivider, Text } from '@chakra-ui/react';
import {
MenuItemComponent,
MenuListComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { SettingsIcon } from '@assets';
import { Box, HStack, Menu, VStack } from '@chakra-ui/react';
import { SettingsIcon } from '@assets';
import { MenuListComponent, TopBarButton } from '@components';
import {
darkModeColorSelector,
settingsStore,
useShallow,
} from '@settingsStore';
import { useTranslation } from 'react-i18next';

const Settings = () => {
const { t } = useTranslation();
const { iconColor } = settingsStore(useShallow(darkModeColorSelector));

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { fireEvent, render, renderHook, screen } from '@testing-library/react';
import Battery from '../Battery';
import { fireEvent, render, screen } from '@testing-library/react';
import DateTimeDrawer from '../DateTimeDrawer';
import { uiStore } from '@uiStore';

describe('DateTime drawer', () => {
it('should render correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { fireEvent, render, screen } from '@testing-library/react';
import Monitor from '../Monitor';
import { renderHook } from '@testing-library/react-hooks';
import {
displayBrightnessSelector,
displayDarkModeSelector,
displayNightShiftSelector,
displayTrueToneSelector,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { fireEvent, render, screen } from '@testing-library/react';
import Wifi from '../Wifi';
import { settingsStore } from '@settingsStore';
import { renderHook } from '@testing-library/react-hooks';

describe('Wifi', () => {
it('should render', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/private/Home/TopBar/TopBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Text } from '@chakra-ui/react';
import { Box } from '@chakra-ui/react';
import { TopBarProps } from './type';
import RightSideIcons from './RightSideIcons';
import LeftSideIcons from './LeftSideIcons';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Img, Text, Tooltip } from '@chakra-ui/react';
import { Box, Img, Text } from '@chakra-ui/react';
import { ProgramButtonProps } from './types';
import {
darkModeColorSelector,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { ProgramType } from '@processStore';

export type ProgramButtonProps = {
name: string;
icon: string;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GithubState, appStore, githubSelector } from '@appStore';
import { Box, Button, ButtonGroup } from '@chakra-ui/react';
import { Box, Button } from '@chakra-ui/react';
import { useShallow } from 'zustand/react/shallow';

const projectList = [
Expand Down
4 changes: 2 additions & 2 deletions src/screens/private/program/Notes/__tests__/Notes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Notes', () => {
});

it('should select and deselect on clicking on card', () => {
const { result } = renderHook(() => appStore());
renderHook(() => appStore());
const { container } = render(<Notes />);

fireEvent.click(screen.getByLabelText('add-note'));
Expand All @@ -52,7 +52,7 @@ describe('Notes', () => {
});

it('should select all on clicking select all', () => {
const { result } = renderHook(() => appStore());
renderHook(() => appStore());
const { container } = render(<Notes />);
// Adding notes
fireEvent.click(screen.getByLabelText('add-note'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fireEvent, render, screen } from '@testing-library/react';
import Spotify from '../Spotify';
import { act, renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react-hooks';
import { appStore, spotifySelector } from '@appStore';

describe('Spotify', () => {
Expand Down
2 changes: 0 additions & 2 deletions src/screens/public/Lock/component/TopRightComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import {
PopoverContent,
PopoverTrigger,
Portal,
useBoolean,
} from '@chakra-ui/react';
import { useTranslation } from 'react-i18next';

const TopRightComponent = () => {
const { t } = useTranslation();
const [keyboard, keyBoardToggle] = useBoolean();

return (
<Box
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { renderHook } from '@testing-library/react-hooks';
import { Power, processStore } from '@processStore';
import { processStore } from '@processStore';
import { loginSelector } from '../Login.selector';

describe('Login selector', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { renderHook } from '@testing-library/react-hooks';
import { ProgramType, WindowSize, processStore } from '@processStore';
import { position } from '@chakra-ui/react';

describe('ActiveApps slice', () => {
it('should return default ActiveApp state', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { BottomBar } from 'src/screens/private/Home/BottomBar';
import { SettingsStoreState } from '../../settingsStore';

const displayBrightnessSelector = (state: SettingsStoreState) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ describe('Modal selector', () => {
});

it('should return modal state on modal data set using openModal', () => {
const modalData: ModalState = {
modalID: ModalID.SEARCH,
modalData: {
onModalClose: onModalCloseMock,
},
modalOpenState: ModalOpenState.OPEN,
};
const { result: modalResult } = renderHook(() => uiStore(modalSelector));
const { result: dataResult } = renderHook(() => uiStore(modalDataSelector));

Expand Down
1 change: 0 additions & 1 deletion src/store/uiStore/slice/Modal/Modal.slice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { warn } from 'console';
import { UiStoreSlice } from '../../uiStore/types';
import { ModalState, ModalStateSlice, ModalOpenState, ModalID } from './types';

Expand Down

0 comments on commit c121db3

Please sign in to comment.