카테고리 없음

Nest.js | UNIT TESTING | Update

개발자티포 2021. 9. 30. 13:51
728x90
반응형

마지막인 Update를 테스트 하기 위해 코드를 추가해보자.

  describe("update", () => {

    it("should update ", () => {
      service.create({
        title: 'Test Movie',
        genres: ['test'],
        year: 2000
      });
      service.update(1, {title:"Updated Test"});
      const movie = service.getOne(1);
      expect(movie.title).toEqual("Updated Test");
    });
    
    it("should throw a NotFoundException", () => {
      try {
        service.update(999, {});
      }
      catch(e){
        expect(e).toBeInstanceOf(NotFoundException)
      }
    });

  });

 

테스트 결과를 확인해보면!

 

 

정상적으로 수행되었다.

728x90
반응형