Skip to content
This repository was archived by the owner on Oct 5, 2020. It is now read-only.

Commit 9fa7340

Browse files
committed
fixing unit tests in map theme
1 parent 3b41edc commit 9fa7340

File tree

4 files changed

+130
-0
lines changed

4 files changed

+130
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* jshint -W117, -W030 */
2+
(function() {
3+
'use strict';
4+
5+
describe('Controller: DetailCtrl', function() {
6+
7+
var controller;
8+
var doc;
9+
10+
beforeEach(function() {
11+
bard.appModule('app.detail');
12+
bard.inject('$controller', '$rootScope', 'MLUiGmapManager', 'uiGmapGoogleMapApi');
13+
14+
// stub the document
15+
var headers = function() {
16+
return 'application/json'; };
17+
doc = {
18+
headers: headers,
19+
data: {
20+
name: 'hi',
21+
location: {
22+
latitude: 1,
23+
longitude: 2
24+
}
25+
}
26+
};
27+
controller = $controller('DetailCtrl', { doc: doc });
28+
$rootScope.$apply();
29+
});
30+
31+
it('should be created successfully', function() {
32+
expect(controller).to.be.defined;
33+
});
34+
35+
it('should have the doc data we gave it', function() {
36+
expect(controller.doc).to.eq(doc.data);
37+
});
38+
39+
});
40+
}());
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(function () {
2+
'use strict';
3+
4+
angular.module('app.detail', [
5+
'app.similar',
6+
'ui.router',
7+
'app.root',
8+
'uiGmapgoogle-maps'
9+
]);
10+
}());
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/* jshint -W117, -W030 */
2+
(function() {
3+
'use strict';
4+
5+
describe('Controller: SearchCtrl', function() {
6+
7+
var controller;
8+
9+
var currentUser = null;
10+
11+
var results = [{
12+
uri: 'abc',
13+
extracted: {
14+
content: [{
15+
location: {
16+
latitude: 1,
17+
longitude: 2
18+
}
19+
}]
20+
}
21+
}, {
22+
uri: 'def',
23+
extracted: {
24+
content: [{
25+
location: {
26+
latitude: 1,
27+
longitude: 2
28+
}
29+
}]
30+
}
31+
}];
32+
33+
beforeEach(function() {
34+
bard.appModule('app.search');
35+
bard.inject('$controller', '$q', '$rootScope', '$location',
36+
'userService', 'MLSearchFactory', 'MLRest', 'MLUiGmapManager', 'uiGmapGoogleMapApi');
37+
38+
bard.mockService(userService, {
39+
currentUser: $q.when(currentUser)
40+
});
41+
42+
bard.mockService(MLRest, {
43+
search: $q.when({
44+
data: {
45+
results: results
46+
}
47+
})
48+
});
49+
50+
});
51+
52+
beforeEach(function() {
53+
controller = $controller('SearchCtrl', { $scope: $rootScope.$new() });
54+
$rootScope.$apply();
55+
});
56+
57+
it('should be created successfully', function() {
58+
expect(controller).to.be.defined;
59+
});
60+
61+
it('should update the current user if it changes', function() {
62+
expect(controller.currentUser).to.not.be.defined;
63+
});
64+
65+
it('should run a search', function() {
66+
controller.search('stuff');
67+
$rootScope.$apply();
68+
expect(controller.response.results).to.eq(results);
69+
});
70+
});
71+
}());
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(function () {
2+
'use strict';
3+
4+
angular.module('app.search', ['ml.search',
5+
'app.user',
6+
'app.snippet',
7+
'app.root',
8+
'uiGmapgoogle-maps']);
9+
}());

0 commit comments

Comments
 (0)