juice-shop

Форк
0
/
security-answer.service.spec.ts 
37 строк · 1.2 Кб
1
/*
2
 * Copyright (c) 2014-2024 Bjoern Kimminich & the OWASP Juice Shop contributors.
3
 * SPDX-License-Identifier: MIT
4
 */
5

6
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'
7
import { fakeAsync, inject, TestBed, tick } from '@angular/core/testing'
8

9
import { SecurityAnswerService } from './security-answer.service'
10

11
describe('SecurityAnswerService', () => {
12
  beforeEach(() => {
13
    TestBed.configureTestingModule({
14
      imports: [HttpClientTestingModule],
15
      providers: [SecurityAnswerService]
16
    })
17
  })
18

19
  it('should be created', inject([SecurityAnswerService], (service: SecurityAnswerService) => {
20
    expect(service).toBeTruthy()
21
  }))
22

23
  it('should create feedback directly via the rest api', inject([SecurityAnswerService, HttpTestingController],
24
    fakeAsync((service: SecurityAnswerService, httpMock: HttpTestingController) => {
25
      let res: any
26
      service.save(null).subscribe((data) => (res = data))
27
      const req = httpMock.expectOne('http://localhost:3000/api/SecurityAnswers/')
28
      req.flush({ data: 'apiResponse' })
29

30
      tick()
31
      expect(req.request.method).toBe('POST')
32
      expect(req.request.body).toBeFalsy()
33
      expect(res).toBe('apiResponse')
34
      httpMock.verify()
35
    })
36
  ))
37
})
38

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.