-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.js
96 lines (77 loc) · 1.93 KB
/
test.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
describe('angular namespacer', function () {
'use strict';
var $injector;
function bootstrap () {
// jshint camelcase:false
module('aww');
inject(function (_$injector_) {
$injector = _$injector_;
});
}
beforeEach(function () {
angular.module('aww', []);
});
it('should namespace the module names', function () {
angular
.module('aww')
.namespace()
.factory('yiss', angular.noop);
bootstrap();
expect($injector.has('aww.yiss')).to.be.true;
});
it('should allow you to override the default delimiter', function () {
angular
.module('aww')
.namespace({
delimiter: '_'
})
.factory('yiss', angular.noop);
bootstrap();
expect($injector.has('aww_yiss')).to.be.true;
});
it('should ignore delimiter and camel case names if asked', function () {
angular
.module('aww')
.namespace({
camelCase: true
})
.factory('yiss', angular.noop);
bootstrap();
expect($injector.has('awwYiss')).to.be.true;
});
it('should only namespace specified methods', function () {
angular
.module('aww')
.namespace({
methods: ['factory']
})
.value('yeah', true)
.factory('yiss', angular.noop);
bootstrap();
expect($injector.has('aww.yiss')).to.be.true;
expect($injector.has('aww.yeah')).to.be.false;
expect($injector.has('yeah')).to.be.true;
});
it('should allow the user to set defaults to be applied', function () {
angular
.module('ns', [])
.value('config', {
delimiter: '_'
});
/**
angular
.module('ns', [])
.config(function (NamespaceProvider) {
NamespaceProvider.config({
delimiter: '_'
});
})
*/
angular
.module('aww')
.namespace()
.factory('yiss', angular.noop);
bootstrap();
expect($injector.has('aww_yiss')).to.be.true;
});
});