|
1 | | -import { CrashDetails, ProcessingStatus } from '@crash'; |
2 | | -import { EventStreamActionType } from '@events'; |
| 1 | +import { AdditionalInfo, ProcessingStatus } from '@crash'; |
3 | 2 | import { createFakeCrashApiResponse } from '@spec/fakes/crash/crash-api-response'; |
4 | 3 | import ac from 'argument-contracts'; |
| 4 | +import { createEvents } from '../../events/events-api-client/event'; |
5 | 5 | import * as ThreadCollectionModule from '../thread-collection/thread-collection'; |
| 6 | +import { createCrashDetails } from './crash-details'; |
6 | 7 |
|
7 | | -describe('Crash Details', () => { |
| 8 | +describe('createCrashDetails', () => { |
8 | 9 | it('should set all properties', () => { |
9 | | - const options = createFakeCrashApiResponse(); |
| 10 | + const options: any = createFakeCrashApiResponse(); |
10 | 11 |
|
11 | | - const result = new CrashDetails(options); |
| 12 | + const result = createCrashDetails(options); |
12 | 13 |
|
13 | | - Object.keys(options).forEach(key => { |
14 | | - if (key !== 'events') { |
15 | | - expect(options[key]).toEqual(result[key]); |
16 | | - } else { |
17 | | - expect(result.events).toEqual(jasmine.arrayContaining([ |
18 | | - jasmine.objectContaining({ |
19 | | - action: EventStreamActionType.comment, |
20 | | - createdDate: new Date(options.events[0].timestamp), |
21 | | - subject: { |
22 | | - initials: options.events[0].username.substring(0, 2), |
23 | | - email: options.events[0].username, |
24 | | - }, |
25 | | - message: options.events[0].message, |
26 | | - }) |
27 | | - ])); |
28 | | - } |
| 14 | + expect(result).toEqual({ |
| 15 | + ...options, |
| 16 | + events: createEvents(options.events), |
| 17 | + additionalInfo: jasmine.any(AdditionalInfo), |
29 | 18 | }); |
30 | 19 | }); |
31 | 20 |
|
@@ -56,7 +45,7 @@ describe('Crash Details', () => { |
56 | 45 | thread: (<any>{ stackFrames: [], stackKeyId: 0 }) |
57 | 46 | }; |
58 | 47 |
|
59 | | - const result = new CrashDetails(<any>options); |
| 48 | + const result = createCrashDetails(<any>options); |
60 | 49 |
|
61 | 50 | expect(result.comments).toEqual(''); |
62 | 51 | expect(result.description).toEqual(''); |
|
0 commit comments