Merge branch 'feature/17-automated_tests' of git.odit.services:lfk/backend into feature/17-automated_tests
This commit is contained in:
		@@ -68,5 +68,12 @@
 | 
				
			|||||||
    "build": "tsc",
 | 
					    "build": "tsc",
 | 
				
			||||||
    "docs": "typedoc --out docs src",
 | 
					    "docs": "typedoc --out docs src",
 | 
				
			||||||
    "test": "jest"
 | 
					    "test": "jest"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "nodemonConfig": {
 | 
				
			||||||
 | 
					    "ignore": [
 | 
				
			||||||
 | 
					      "src/tests/*",
 | 
				
			||||||
 | 
					      "docs/*"
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "delay": "2500"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -56,3 +56,47 @@ describe('adding + getting tracks', () => {
 | 
				
			|||||||
		})
 | 
							})
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					// ---------------
 | 
				
			||||||
 | 
					describe('adding + getting + updating', () => {
 | 
				
			||||||
 | 
						let added_track_id
 | 
				
			||||||
 | 
						it('correct distance input should return 200', async () => {
 | 
				
			||||||
 | 
							const res = await axios.post('http://localhost:4010/api/tracks', {
 | 
				
			||||||
 | 
								"name": "string",
 | 
				
			||||||
 | 
								"distance": 1500
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
							expect(res.status).toEqual(200);
 | 
				
			||||||
 | 
							expect(res.headers['content-type']).toContain("application/json")
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
 | 
						it('get should return 200', async () => {
 | 
				
			||||||
 | 
							const res1 = await axios.get('http://localhost:4010/api/tracks');
 | 
				
			||||||
 | 
							expect(res1.status).toEqual(200);
 | 
				
			||||||
 | 
							expect(res1.headers['content-type']).toContain("application/json")
 | 
				
			||||||
 | 
							let added_track = res1.data[res1.data.length - 1]
 | 
				
			||||||
 | 
							added_track_id = added_track.id
 | 
				
			||||||
 | 
							delete added_track.id
 | 
				
			||||||
 | 
							expect(added_track).toEqual({
 | 
				
			||||||
 | 
								"name": "string",
 | 
				
			||||||
 | 
								"distance": 1500
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						it('get should return 200', async () => {
 | 
				
			||||||
 | 
							const res2 = await axios.put('http://localhost:4010/api/tracks/' + added_track_id, {
 | 
				
			||||||
 | 
								"id": added_track_id,
 | 
				
			||||||
 | 
								"name": "apitrack",
 | 
				
			||||||
 | 
								"distance": 5100
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
							expect(res2.status).toEqual(200);
 | 
				
			||||||
 | 
							expect(res2.headers['content-type']).toContain("application/json")
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						it('get should return 200', async () => {
 | 
				
			||||||
 | 
							const res3 = await axios.get('http://localhost:4010/api/tracks');
 | 
				
			||||||
 | 
							expect(res3.status).toEqual(200);
 | 
				
			||||||
 | 
							expect(res3.headers['content-type']).toContain("application/json")
 | 
				
			||||||
 | 
							let added_track2 = res3.data[res3.data.length - 1]
 | 
				
			||||||
 | 
							delete added_track2.id
 | 
				
			||||||
 | 
							expect(added_track2).toEqual({
 | 
				
			||||||
 | 
								"name": "apitrack",
 | 
				
			||||||
 | 
								"distance": 5100
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user