From ba14ca1830fefd5af1fa921490abe7f88699b034 Mon Sep 17 00:00:00 2001 From: Inga <52715130+inga-lovinde@users.noreply.github.com> Date: Mon, 11 Dec 2023 12:58:14 +0000 Subject: [PATCH] minor test improvements --- package.json | 2 +- solution.md | 2 +- src/movies.controller.spec.ts | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d227add..81e11dc 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "lint": "eslint \"{src,apps,libs,test}/**/*.ts\"", "test": "jest", "test:watch": "jest --watch", - "test:cov": "jest --coverage", + "test:cov": "npm run test -- --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "OMDB_API_KEY=68fd98ab jest --config ./test/jest-e2e.json" }, diff --git a/solution.md b/solution.md index 42920fa..6badf4b 100644 --- a/solution.md +++ b/solution.md @@ -189,7 +189,7 @@ who did not enter any search filters), so I return a 400 Bad Request errors for ## Testing -The code is mostly covered by tests. +The code is mostly (according to `npm run test:cov`, plus e2e tests) covered by tests. I did not have any time to come up with good test cases, so most tests work on samples of data from OMDB and on provided sample JSONs. diff --git a/src/movies.controller.spec.ts b/src/movies.controller.spec.ts index feab179..ae411bc 100644 --- a/src/movies.controller.spec.ts +++ b/src/movies.controller.spec.ts @@ -32,8 +32,16 @@ describe('AppController', () => { }); }); + it('should return 404 for unknown imdb id', () => { + expect(() => moviesController.getMovie('tt7394674')).toThrow( + 'Not Found', + ); + }); + it('should throw an error for empty search query', () => { - expect(() => moviesController.searchMovies({})).toThrow(); + expect(() => moviesController.searchMovies({})).toThrow( + 'Query should not be empty', + ); }); it('should return movies matching writer', () => {