]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; |
2 | import { TestBed } from '@angular/core/testing'; | |
3 | ||
f67539c2 | 4 | import { configureTestBed } from '~/testing/unit-test-helper'; |
11fdf7f2 TL |
5 | import { LoggingService } from './logging.service'; |
6 | ||
7 | describe('LoggingService', () => { | |
8 | let service: LoggingService; | |
9 | let httpTesting: HttpTestingController; | |
10 | ||
11 | configureTestBed({ | |
12 | providers: [LoggingService], | |
13 | imports: [HttpClientTestingModule] | |
14 | }); | |
15 | ||
16 | beforeEach(() => { | |
f67539c2 TL |
17 | service = TestBed.inject(LoggingService); |
18 | httpTesting = TestBed.inject(HttpTestingController); | |
11fdf7f2 TL |
19 | }); |
20 | ||
21 | afterEach(() => { | |
22 | httpTesting.verify(); | |
23 | }); | |
24 | ||
25 | it('should be created', () => { | |
26 | expect(service).toBeTruthy(); | |
27 | }); | |
28 | ||
29 | it('should call jsError', () => { | |
30 | service.jsError('foo', 'bar', 'baz').subscribe(); | |
31 | const req = httpTesting.expectOne('ui-api/logging/js-error'); | |
32 | expect(req.request.method).toBe('POST'); | |
33 | expect(req.request.body).toEqual({ | |
34 | url: 'foo', | |
35 | message: 'bar', | |
36 | stack: 'baz' | |
37 | }); | |
38 | }); | |
39 | }); |