-
Notifications
You must be signed in to change notification settings - Fork 1
/
disallow-appinstancecontainer.js
62 lines (52 loc) · 1.73 KB
/
disallow-appinstancecontainer.js
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
describe('lib/rules/disallow-appinstancecontainer', function () {
var checker = global.checker({
plugins: ['./lib/index']
});
describe('not configured', function() {
it('should report with undefined', function() {
global.expect(function() {
checker.configure({disallowAppInstanceContainer: undefined});
}).to.throws(/requires a true value/i);
});
it('should report with an object', function() {
global.expect(function() {
checker.configure({disallowAppInstanceContainer: {}});
}).to.throws(/requires a true value/i);
});
});
describe('with true', function() {
checker.rules({disallowAppInstanceContainer: true});
checker.cases([
/* jshint ignore:start */
{
it: 'should not report appinstance.lookup',
filename: 'app/initializer/foo.js',
code: function() {
var initialize = function(appInstance) {
var store = appInstance.lookup('service:store');
store.pushPayload('<payload here>');
}
return {
name: 'preload-store',
initialize: initialize
}
}
}, {
it: 'should report appinstance.container',
filename: 'app/initializer/foo.js',
errors: 1,
code: function() {
var initialize = function(appInstance) {
var store = appInstance.container.lookup('service:store');
store.pushPayload('<payload here>');
}
return {
name: 'preload-store',
initialize: initialize
}
}
}
/* jshint ignore:end */
]);
});
});