Skip to content

Commit

Permalink
cleanup migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Dereje1 committed Apr 20, 2023
1 parent c7d530f commit 34c9f4b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 65 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ nodemon.json
/myscripts
.DS_Store
/server_build
google_vision_api_key.json
google_vision_api_key.json
/client/dist
24 changes: 0 additions & 24 deletions client/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion client/src/components/modal/Front/SwipableImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ function SwipableImage({ zoomInfo, onSlidePin, onSetImageMetaData }: SwipableIma
marginLeft: 'auto',
marginRight: 'auto',
objectFit: 'contain',
borderColor: 'black',
border: parentDivStyle.border,
}}
onLoad={onPinLoad}
Expand Down
11 changes: 0 additions & 11 deletions client/src/components/signin/logout.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
import { useEffect } from 'react';
import { useHistory } from 'react-router-dom';
import { useDispatch } from 'react-redux';
import { getUser } from '../../actions/authentication';
import RESTcall from '../../crud';

function LogOut() {
const history = useHistory();
const dispatch = useDispatch();

const logout = async () => {
// TODO: vite erroring out on axios rest call to auth/logout
// await RESTcall({ address: '/auth/logout' });
// dispatch(getUser('/auth/profile'));
// history.replace('/logout');
window.location.assign('/auth/logout');
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ exports[`will render with the list item bar 1`] = `
sx={
{
"border": 0,
"borderColor": "black",
"height": 500,
"marginLeft": "auto",
"marginRight": "auto",
Expand Down Expand Up @@ -98,7 +97,6 @@ exports[`will render without the list item bar 1`] = `
sx={
{
"border": 0,
"borderColor": "black",
"height": 500,
"marginLeft": "auto",
"marginRight": "auto",
Expand Down
37 changes: 11 additions & 26 deletions tests/client/src/components/signin/logout.test.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
/**
* @jest-environment jsdom
*/
import React from 'react';
import { shallow } from 'enzyme';
import * as router from 'react-router-dom';
import LogOut from '../../../../../client/src/components/signin/logout';
import RESTcall from '../../../../../client/src/crud';

const mockdispatch = jest.fn();
// Mock RESTcall
jest.mock('../../../../../client/src/crud');
// Mock redux hooks
jest.mock('react-redux', () => ({
...jest.requireActual('react-redux'), // use actual for all non-hook parts
useDispatch: jest.fn(() => mockdispatch),
}));

// Mock router hooks
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'), // use actual for all non-hook parts
useHistory: jest.fn(),
}));
const windowSpy = jest.spyOn(window, 'location', 'get');
const mockedAssign: jest.Mock = jest.fn();
windowSpy.mockReturnValue({
...window.location,
assign: mockedAssign,
});

xtest('will logout a user', async () => {
const replace = jest.fn();
const hist = router.useHistory();
jest
.spyOn(router, 'useHistory')
.mockImplementation(() => ({ ...hist, replace }));
test('will logout a user', () => {
shallow(<LogOut />);
await Promise.resolve();
expect(RESTcall).toHaveBeenCalledWith({ address: '/auth/logout' });
expect(mockdispatch).toHaveBeenCalled();
expect(replace).toHaveBeenCalledWith('/');
expect(mockedAssign).toHaveBeenCalledWith('/auth/logout');
});

0 comments on commit 34c9f4b

Please sign in to comment.