Skip to content

Commit

Permalink
Update linting of files using eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
agupta15k committed Oct 9, 2022
1 parent d8c0a1c commit fd59f33
Show file tree
Hide file tree
Showing 34 changed files with 1,486 additions and 1,453 deletions.
29 changes: 29 additions & 0 deletions src/frontend/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
.pnp
.pnp.js

# testing
coverage

# production
build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
package.json
package-lock.json
public
.eslintrc.js
__snapshots__
*.css
3 changes: 2 additions & 1 deletion src/frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
'env': {
'browser': true,
'es2021': true
'es2021': true,
'jest': true
},
'extends': [
'eslint:recommended',
Expand Down
50 changes: 25 additions & 25 deletions src/frontend/src/__tests__/API/addItem.spec.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import addItemApi from "../../API/addItem";
import addItemApi from '../../API/addItem';
import axios from '../../axios';

describe('addItemApi', () => {
it('should call axios post with correct input', () => {
const mockApiInput = {
itemName: 'test',
itemQuantity: 1,
itemDescription: 'test',
itemZipCode: 'test',
itemCity: 'test',
itemDonorId: 1,
itemCategory: 'test'
};
const expectedApiInput = {
item_name: 'test',
quantity: 1,
description: 'test',
zipcode: 'test',
city: 'test',
donor_id: 1,
category: 'test'
};
axios.post = jest.fn();
addItemApi(mockApiInput);
expect(axios.post).toHaveBeenCalledWith('/additem', expectedApiInput);
jest.clearAllMocks();
});
it('should call axios post with correct input', () => {
const mockApiInput = {
itemName: 'test',
itemQuantity: 1,
itemDescription: 'test',
itemZipCode: 'test',
itemCity: 'test',
itemDonorId: 1,
itemCategory: 'test'
};
const expectedApiInput = {
item_name: 'test',
quantity: 1,
description: 'test',
zipcode: 'test',
city: 'test',
donor_id: 1,
category: 'test'
};
axios.post = jest.fn();
addItemApi(mockApiInput);
expect(axios.post).toHaveBeenCalledWith('/additem', expectedApiInput);
jest.clearAllMocks();
});
});
12 changes: 6 additions & 6 deletions src/frontend/src/__tests__/API/getDonorHistory.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import getDonorHistoryAPI from '../../API/getDonorHistory';
import axios from '../../axios';

describe('getDonorHistoryAPI', () => {
it('should call axios get with correct input', () => {
axios.get = jest.fn();
getDonorHistoryAPI(1);
expect(axios.get).toHaveBeenCalledWith('/donor/history?id=1');
jest.clearAllMocks();
});
it('should call axios get with correct input', () => {
axios.get = jest.fn();
getDonorHistoryAPI(1);
expect(axios.get).toHaveBeenCalledWith('/donor/history?id=1');
jest.clearAllMocks();
});
});
12 changes: 6 additions & 6 deletions src/frontend/src/__tests__/API/getProfile.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import getProfleAPI from '../../API/getProfile';
import axios from '../../axios';

describe('getProfleAPI', () => {
it('should call axios get with correct input', () => {
axios.get = jest.fn();
getProfleAPI(1);
expect(axios.get).toHaveBeenCalledWith('/profile?id=1');
jest.clearAllMocks();
});
it('should call axios get with correct input', () => {
axios.get = jest.fn();
getProfleAPI(1);
expect(axios.get).toHaveBeenCalledWith('/profile?id=1');
jest.clearAllMocks();
});
});
12 changes: 6 additions & 6 deletions src/frontend/src/__tests__/API/getRecipientHistory.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import getRecipientHistoryAPI from '../../API/getRecipientHistory';
import axios from '../../axios';

describe('getRecipientHistoryAPI', () => {
it('should call axios get with correct input', () => {
axios.get = jest.fn();
getRecipientHistoryAPI(1);
expect(axios.get).toHaveBeenCalledWith('/recipient/history?id=1');
jest.clearAllMocks();
});
it('should call axios get with correct input', () => {
axios.get = jest.fn();
getRecipientHistoryAPI(1);
expect(axios.get).toHaveBeenCalledWith('/recipient/history?id=1');
jest.clearAllMocks();
});
});
12 changes: 6 additions & 6 deletions src/frontend/src/__tests__/API/getRecipientItems.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import getRecipientItemsAPI from '../../API/getRecipientItems';
import axios from '../../axios';

describe('getRecipientItemsAPI', () => {
it('should call axios get with correct input', () => {
axios.get = jest.fn();
getRecipientItemsAPI(1);
expect(axios.get).toHaveBeenCalledWith('/items?page=1&id=1');
jest.clearAllMocks();
});
it('should call axios get with correct input', () => {
axios.get = jest.fn();
getRecipientItemsAPI(1);
expect(axios.get).toHaveBeenCalledWith('/items?page=1&id=1');
jest.clearAllMocks();
});
});
28 changes: 14 additions & 14 deletions src/frontend/src/__tests__/API/login.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import loginAPI from '../../API/login';
import axios from '../../axios';

describe('loginAPI', () => {
it('should call axios post with correct input', () => {
const mockApiInput = {
email: 'test@test.com',
pass: 'test'
};
const expectedApiInput = {
email: 'test@test.com',
password: 'test'
};
axios.post = jest.fn();
loginAPI(mockApiInput);
expect(axios.post).toHaveBeenCalledWith('/login', expectedApiInput);
jest.clearAllMocks();
});
it('should call axios post with correct input', () => {
const mockApiInput = {
email: 'test@test.com',
pass: 'test'
};
const expectedApiInput = {
email: 'test@test.com',
password: 'test'
};
axios.post = jest.fn();
loginAPI(mockApiInput);
expect(axios.post).toHaveBeenCalledWith('/login', expectedApiInput);
jest.clearAllMocks();
});
});
28 changes: 14 additions & 14 deletions src/frontend/src/__tests__/API/receiveItem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import recieveItemAPI from '../../API/recieveItem';
import axios from '../../axios';

describe('recieveItemAPI', () => {
it('should call axios put with correct input', () => {
const mockApiInput = {
itemId: 1,
userId: 1
};
const expectedApiInput = {
itemId: 1,
userId: 1
};
axios.put = jest.fn();
recieveItemAPI(mockApiInput);
expect(axios.put).toHaveBeenCalledWith('/items/recieve', expectedApiInput);
jest.clearAllMocks();
});
it('should call axios put with correct input', () => {
const mockApiInput = {
itemId: 1,
userId: 1
};
const expectedApiInput = {
itemId: 1,
userId: 1
};
axios.put = jest.fn();
recieveItemAPI(mockApiInput);
expect(axios.put).toHaveBeenCalledWith('/items/recieve', expectedApiInput);
jest.clearAllMocks();
});
});
48 changes: 24 additions & 24 deletions src/frontend/src/__tests__/API/registerUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ import registerUserApi from '../../API/registerUser';
import axios from '../../axios';

describe('registerUserApi', () => {
it('should call axios post with correct input', () => {
const mockApiInput = {
name: 'test',
email: 'test@test.com',
pass: 'test',
rePass: 'test',
cities: ['city1', 'city2'],
zipCodes: ['123', '234'],
interests: ['interest1', 'interest2']
};
const expectedApiInput = {
name: 'test',
email: 'test@test.com',
password: 'test',
repeatpassword: 'test',
city: ['city1', 'city2'],
zipcode: ['123', '234'],
interests: ['interest1', 'interest2']
};
axios.post = jest.fn();
registerUserApi(mockApiInput);
expect(axios.post).toHaveBeenCalledWith('/register', expectedApiInput);
jest.clearAllMocks();
});
it('should call axios post with correct input', () => {
const mockApiInput = {
name: 'test',
email: 'test@test.com',
pass: 'test',
rePass: 'test',
cities: ['city1', 'city2'],
zipCodes: ['123', '234'],
interests: ['interest1', 'interest2']
};
const expectedApiInput = {
name: 'test',
email: 'test@test.com',
password: 'test',
repeatpassword: 'test',
city: ['city1', 'city2'],
zipcode: ['123', '234'],
interests: ['interest1', 'interest2']
};
axios.post = jest.fn();
registerUserApi(mockApiInput);
expect(axios.post).toHaveBeenCalledWith('/register', expectedApiInput);
jest.clearAllMocks();
});
});
30 changes: 15 additions & 15 deletions src/frontend/src/__tests__/API/updateProfile.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import updateProfileAPI from '../../API/updateProfile';
import axios from '../../axios';

describe('updateProfileAPI', () => {
it('should call axios put with correct input', () => {
const mockApiInput = {
id: 1,
name: 'abc',
email: 'test@test.com',
city: ['raleigh', 'durham', 'charlotte'],
zipCodes: ['12345', '27606'],
password: 'abcdef',
interests: []
};
axios.put = jest.fn();
updateProfileAPI(mockApiInput);
expect(axios.put).toHaveBeenCalledWith('/profile', mockApiInput);
jest.clearAllMocks();
});
it('should call axios put with correct input', () => {
const mockApiInput = {
id: 1,
name: 'abc',
email: 'test@test.com',
city: ['raleigh', 'durham', 'charlotte'],
zipCodes: ['12345', '27606'],
password: 'abcdef',
interests: []
};
axios.put = jest.fn();
updateProfileAPI(mockApiInput);
expect(axios.put).toHaveBeenCalledWith('/profile', mockApiInput);
jest.clearAllMocks();
});
});
12 changes: 6 additions & 6 deletions src/frontend/src/__tests__/app/store.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import importStore from '../../app/store';


describe('reduxStore', () => {
it('store should be set correctly', () => {
const store = configureStore({
reducer
});
expect(JSON.stringify(store)).toEqual(JSON.stringify(importStore));
});
it('store should be set correctly', () => {
const store = configureStore({
reducer
});
expect(JSON.stringify(store)).toEqual(JSON.stringify(importStore));
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`donateComponent renders without crashing 1`] = `
exports['donateComponent renders without crashing 1'] = `
<section>
<div
className="container"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`loginComponent renders without crashing 1`] = `
exports['loginComponent renders without crashing 1'] = `
<section>
<div
className="signup"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`registerUserComponent renders without crashing 1`] = `
exports['registerUserComponent renders without crashing 1'] = `
<div
className="signup"
>
Expand Down
Loading

0 comments on commit fd59f33

Please sign in to comment.