forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfiguration-spec.ts
More file actions
63 lines (52 loc) · 2.52 KB
/
Configuration-spec.ts
File metadata and controls
63 lines (52 loc) · 2.52 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
import { Configuration } from './Configuration';
import { EventPluginContext } from '../plugins/EventPluginContext';
describe('Configuration', () => {
it('should override configuration defaults', () => {
var config = new Configuration();
expect(config.apiKey).toBe(null);
config.apiKey = 'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw';
expect(config.apiKey).toBe('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw');
Configuration.defaults.apiKey = 'test';
config = new Configuration();
expect(config.apiKey).toBe('test');
config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
expect(config.apiKey).toBe('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw');
config = new Configuration({ apiKey:null });
expect(config.apiKey).toBe('test');
});
it('should not add duplicate plugin', () => {
var config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
expect(config.plugins).not.toBe(null);
while(config.plugins.length > 0) {
config.removePlugin(config.plugins[0]);
}
config.addPlugin('test', 20, (context:EventPluginContext) => {});
config.addPlugin('test', 20, (context:EventPluginContext) => {});
expect(config.plugins.length).toBe(1);
});
it('should generate plugin name and priority', () => {
var config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
expect(config.plugins).not.toBe(null);
while(config.plugins.length > 0) {
config.removePlugin(config.plugins[0]);
}
config.addPlugin(null, null, (context:EventPluginContext) => {});
expect(config.plugins.length).toBe(1);
expect(config.plugins[0].name).not.toBe(null);
expect(config.plugins[0].priority).toBe(0);
});
it('should sort plugins by priority', () => {
var config = new Configuration({ apiKey:'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl:'http://localhost:50000'});
expect(config.plugins).not.toBe(null);
while(config.plugins.length > 0) {
config.removePlugin(config.plugins[0]);
}
config.addPlugin('3', 3, (context:EventPluginContext) => {});
config.addPlugin('1', 1, (context:EventPluginContext) => {});
config.addPlugin('2', 2, (context:EventPluginContext) => {});
expect(config.plugins.length).toBe(3);
expect(config.plugins[0].priority).toBe(1);
expect(config.plugins[1].priority).toBe(2);
expect(config.plugins[2].priority).toBe(3);
});
});