Skip to content

Commit a2eef47

Browse files
committed
refactor: cleanups and formatting
1 parent 2c28d2d commit a2eef47

4 files changed

Lines changed: 8 additions & 31 deletions

File tree

backend/jest.config.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55

66
/** @type {import('jest').Config} */
77
const config = {
8-
// The test environment that will be used for testing
9-
// testEnvironment: "jest-environment-node",
108
testEnvironment: 'node',
11-
12-
// A map from regular expressions to paths to transformers
13-
// transform: undefined,
149
transform: {
1510
'^.+\\.jsx?$': 'babel-jest',
1611
},

backend/src/__test__/app.test.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@ describe('App API Endpoints', () => {
173173
})
174174

175175
it('should keep list completed status as false when not all items are completed', async () => {
176-
const itemOneRes = await createItem( {
176+
const itemOneRes = await createItem({
177177
itemTitle: 'Incomplete Item',
178178
completed: false,
179179
})
180180
expect(itemOneRes.status).toBe(200)
181181

182-
const itemTwoRes = await createItem( {
182+
const itemTwoRes = await createItem({
183183
itemTitle: 'Completed Item',
184184
completed: true,
185185
})
@@ -210,22 +210,18 @@ describe('App API Endpoints', () => {
210210
})
211211

212212
it('should update list completed status to true if all remaining items are completed after deletion', async () => {
213+
const testTodoList = { title: 'The POST list!', completed: true }
213214

214-
const testTodoList = { title: 'The POST list!', completed: true }
215-
216-
217-
const res = await request(app).post('/api/todo-list').send(testTodoList)
218-
expect(res.status).toBe(200)
219-
220-
const testListId = res.body.id
215+
const res = await request(app).post('/api/todo-list').send(testTodoList)
216+
expect(res.status).toBe(200)
221217

218+
const testListId = res.body.id
222219

223220
const itemRes = await request(app)
224221
.post(`/api/todo-list/${testListId}/item`)
225222
.send({ itemTitle: 'Completed Item' })
226223
expect(itemRes.status).toBe(200)
227224

228-
229225
const deleteRes = await request(app).delete(
230226
`/api/todo-list/${testListId}/item/${itemRes.body.id}`
231227
)

backend/src/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
createTodoItem,
77
fetchTodoItemById,
88
updateTodoItem,
9-
deleteTodoItem, createTodoList
9+
deleteTodoItem,
10+
createTodoList,
1011
} from './todo-service.js'
1112

1213
const app = express()

backend/src/todo-service.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,18 @@ const handleListCompletionStatus = async (todoListRepository, listId, itemComple
7777
if (itemCompleted) {
7878
await markListAsCompletedIfAllItemsCompleted(todoListRepository, listId)
7979
} else {
80-
console.log('NOW MARKING THE LIST AS NOT COMPLETED!')
8180
await todoListRepository.update({ id: listId }, { completed: false })
8281
}
8382
}
8483

85-
8684
export const updateTodoItem = async (listId, itemId, updateData) => {
87-
console.log('*** updateTodoItem', listId, itemId, updateData)
8885
const AppDataSource = await getAppDataSource()
8986
const todoRepository = AppDataSource.getRepository(TodoItem)
9087
const todoListRepository = AppDataSource.getRepository(TodoList)
9188

9289
const todoItem = await fetchAndValidateTodoItem(todoRepository, listId, itemId)
9390

9491
const updatedTodoItem = await todoRepository.save(todoRepository.merge(todoItem, updateData))
95-
console.log('updatedTodoItem in memory and in database:', updatedTodoItem)
9692

9793
await handleListCompletionStatus(todoListRepository, listId, updateData.completed)
9894

@@ -108,18 +104,7 @@ export const deleteTodoItem = async (listId, itemId) => {
108104

109105
await todoRepository.delete(itemId)
110106

111-
console.log(">BEFORE", await todoListRepository.findOne({
112-
where: { id: listId },
113-
relations: ['items'],
114-
})
115-
)
116107
await markListAsCompletedIfAllItemsCompleted(todoListRepository, listId)
117108

118-
console.log(">AFTER", await todoListRepository.findOne({
119-
where: { id: listId },
120-
relations: ['items'],
121-
})
122-
)
123-
124109
return todoItem
125110
}

0 commit comments

Comments
 (0)