forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptionlessClient-spec.ts
More file actions
55 lines (44 loc) · 2.24 KB
/
ExceptionlessClient-spec.ts
File metadata and controls
55 lines (44 loc) · 2.24 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
import { ExceptionlessClient } from 'ExceptionlessClient';
import { EventPluginContext } from './plugins/EventPluginContext';
describe('ExceptionlessClient', () => {
it('should use event reference ids', (done) => {
var error = new Error('From Unit Test');
var client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
expect(client.config.lastReferenceIdManager.getLast()).toBe(null);
client.submitException(error, (context:EventPluginContext) => {
expect(client.config.lastReferenceIdManager.getLast()).toBe(null);
});
var numberOfPlugins = client.config.plugins.length;
client.config.useReferenceIds();
expect(client.config.plugins.length).toBe(numberOfPlugins + 1);
client.submitException(error, (context:EventPluginContext) => {
if (!context.cancelled) {
expect(client.config.lastReferenceIdManager.getLast()).not.toBe(null);
} else {
expect(client.config.lastReferenceIdManager.getLast()).toBe(null);
}
done();
});
}, 5000);
it('should accept null source', () => {
var client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
var builder = client.createLog(null, 'Unit Test message', 'Trace');
expect(builder.target.source).toBeUndefined();
expect(builder.target.message).toBe('Unit Test message');
expect(builder.target.data['@level']).toBe('Trace');
});
it('should accept source and message', () => {
var client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
var builder = client.createLog('ExceptionlessClient', 'Unit Test message');
expect(builder.target.source).toBe('ExceptionlessClient');
expect(builder.target.message).toBe('Unit Test message');
expect(builder.target.data).toBeUndefined();
});
it('should accept source and message', () => {
var client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
var builder = client.createLog('Unit Test message');
expect(builder.target.source).toBeUndefined();
expect(builder.target.message).toBe('Unit Test message');
expect(builder.target.data).toBeUndefined();
});
});