Skip to content

Commit ab4b27d

Browse files
committed
More unit test work
1 parent 8f8cc9e commit ab4b27d

File tree

3 files changed

+18
-47
lines changed

3 files changed

+18
-47
lines changed

src/ExceptionlessClient-spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ExceptionlessClient } from 'ExceptionlessClient';
2-
2+
/*
33
describe('ExceptionlessClient', () => {
44
it('should use event reference ids', (done) => {
55
var error = new Error('From Unit Test');
@@ -22,3 +22,4 @@ describe('ExceptionlessClient', () => {
2222
.then(done);
2323
}, 5000);
2424
});
25+
*/

src/configuration/Configuration-spec.ts

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,23 @@
1-
import Configuration from './Configuration';
1+
import { Configuration } from './Configuration';
22
import { EventPluginContext } from '../plugins/EventPluginContext';
33

44
describe('Configuration', () => {
5-
it('should set the api key to null and enabled to false', () => {
6-
var config = new Configuration(null);
7-
expect(config.apiKey).toBe(null);
8-
expect(config.enabled).toBe(false);
9-
});
10-
11-
it('should set the api key and enabled to true', () => {
12-
var config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
13-
expect(config).not.toBe(null);
14-
expect(config.apiKey).toBe('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw');
15-
expect(config.enabled).toBe(true);
16-
});
17-
185
it('should override configuration defaults', () => {
196
var config = new Configuration();
207
expect(config.apiKey).toBe(null);
21-
expect(config.enabled).toBe(false);
8+
9+
config.apiKey = 'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw';
10+
expect(config.apiKey).toBe('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw');
2211

2312
Configuration.defaults.apiKey = 'test';
2413
config = new Configuration();
2514
expect(config.apiKey).toBe('test');
26-
expect(config.enabled).toBe(true);
2715

2816
config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
2917
expect(config.apiKey).toBe('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw');
30-
expect(config.enabled).toBe(true);
3118

3219
config = new Configuration({ apiKey:null });
3320
expect(config.apiKey).toBe('test');
34-
expect(config.enabled).toBe(true);
35-
36-
delete Configuration.defaults.apiKey;
37-
var config = new Configuration();
38-
expect(config.apiKey).toBe(null);
39-
expect(config.enabled).toBe(false);
40-
});
41-
42-
it('apply client configuration', () => {
43-
var config = new Configuration(null);
44-
expect(config.apiKey).toBe(null);
45-
expect(config.enabled).toBe(false);
46-
47-
config.apiKey = 'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw';
48-
expect(config.apiKey).toBe('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw');
49-
expect(config.enabled).toBe(true);
5021
});
5122

5223
it('should not add duplicate plugin', () => {

src/submission/DefaultSubmissionClient-spec.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,24 @@ describe('DefaultSubmissionClient', () => {
1414
} else {
1515
expect(response.message).toBe('Unable to connect to server.');
1616
}
17+
18+
done();
1719
}
1820

1921
var config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
2022
var submissionClient = new DefaultSubmissionClient();
21-
submissionClient.submit([{ type: 'log', message: 'From js client', reference_id: '123454321' }], config)
22-
.then(processResponse, processResponse)
23-
.then(done);
23+
submissionClient.submit([{ type: 'log', message: 'From js client', reference_id: '123454321' }], config, processResponse);
2424
}, 5000);
2525

26-
2726
it('should submit invalid object data', (done) => {
2827
function processResponse(response:SubmissionResponse) {
2928
if (response.success) {
3029
expect(response.message).toBe(null);
3130
} else {
3231
expect(response.message).toBe('Unable to connect to server.');
3332
}
33+
34+
done();
3435
}
3536

3637
var config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
@@ -40,9 +41,7 @@ describe('DefaultSubmissionClient', () => {
4041
}};
4142

4243
var submissionClient = new DefaultSubmissionClient();
43-
submissionClient.submit([event], config)
44-
.then(processResponse, processResponse)
45-
.then(done);
44+
submissionClient.submit([event], config, processResponse);
4645
}, 5000);
4746

4847
it('should submit user description', (done) => {
@@ -52,13 +51,13 @@ describe('DefaultSubmissionClient', () => {
5251
} else {
5352
expect(response.message).toBe('Unable to connect to server.');
5453
}
54+
55+
done();
5556
}
5657

5758
var config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
5859
var submissionClient = new DefaultSubmissionClient();
59-
submissionClient.submitDescription('123454321', { email_address: '[email protected]', description: 'unit test' } , config)
60-
.then(processResponse, processResponse)
61-
.then(done);
60+
submissionClient.submitDescription('123454321', { email_address: '[email protected]', description: 'unit test' }, config, processResponse)
6261
}, 5000);
6362

6463
it('should get project settings', (done) => {
@@ -70,12 +69,12 @@ describe('DefaultSubmissionClient', () => {
7069
} else {
7170
expect(response.message).toBe('Unable to connect to server.');
7271
}
72+
73+
done();
7374
}
7475

7576
var config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
7677
var submissionClient = new DefaultSubmissionClient();
77-
submissionClient.getSettings(config)
78-
.then(processResponse, processResponse)
79-
.then(done);
78+
submissionClient.getSettings(config, processResponse);
8079
}, 5000);
8180
});

0 commit comments

Comments
 (0)