forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultSubmissionClient-spec.ts
More file actions
80 lines (67 loc) · 3.06 KB
/
DefaultSubmissionClient-spec.ts
File metadata and controls
80 lines (67 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { Configuration } from '../configuration/Configuration';
import { IEvent } from '../models/IEvent';
import { IUserDescription } from '../models/IUserDescription';
import { ISubmissionClient } from 'ISubmissionClient';
import { DefaultSubmissionClient } from 'DefaultSubmissionClient';
import { SettingsResponse } from 'SettingsResponse';
import { SubmissionResponse } from 'SubmissionResponse';
describe('DefaultSubmissionClient', () => {
it('should submit events', (done) => {
function processResponse(response:SubmissionResponse) {
if (response.success) {
expect(response.message).toBe(null);
} else {
expect(response.message).toBe('Unable to connect to server.');
}
done();
}
var config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
var submissionClient = new DefaultSubmissionClient();
submissionClient.postEvents([{ type: 'log', message: 'From js client', reference_id: '123454321' }], config, processResponse);
}, 5000);
it('should submit invalid object data', (done) => {
function processResponse(response:SubmissionResponse) {
if (response.success) {
expect(response.message).toBe(null);
} else {
expect(response.message).toBe('Unable to connect to server.');
}
done();
}
var config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
var event:IEvent = { type: 'log', message: 'From js client', reference_id: '123454321', data: {
name: 'blake',
age: function() { throw new Error('Test'); }
}};
var submissionClient = new DefaultSubmissionClient();
submissionClient.postEvents([event], config, processResponse);
}, 5000);
it('should submit user description', (done) => {
function processResponse(response:SubmissionResponse) {
if (response.success) {
expect(response.message).toBe(null);
} else {
expect(response.message).toBe('Unable to connect to server.');
}
done();
}
var config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
var submissionClient = new DefaultSubmissionClient();
submissionClient.postUserDescription('123454321', { email_address: 'norply@exceptionless.io', description: 'unit test' }, config, processResponse)
}, 5000);
it('should get project settings', (done) => {
function processResponse(response:SettingsResponse) {
if (response.success) {
expect(response.message).toBe(null);
expect(response.settings).not.toBe(null);
expect(response.settingsVersion).toBeGreaterThan(-1);
} else {
expect(response.message).toBe('Unable to connect to server.');
}
done();
}
var config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
var submissionClient = new DefaultSubmissionClient();
submissionClient.getSettings(config, processResponse);
}, 5000);
});