Skip to content
This repository was archived by the owner on Sep 15, 2021. It is now read-only.

Commit 11213f3

Browse files
committed
Merge pull request #825 from kfuglsang/master
Added brightness mock
2 parents 87aa655 + 2be8bd4 commit 11213f3

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

src/mocks/brightness.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ngCordovaMocks.factory('$cordovaBrightness', ['$q', function ($q) {
2+
var currentBrightness = 100;
3+
4+
return {
5+
get: function () {
6+
var q = $q.defer();
7+
q.resolve(currentBrightness);
8+
return q.promise;
9+
},
10+
11+
set: function (data) {
12+
var q = $q.defer();
13+
currentBrightness = data;
14+
q.resolve('OK');
15+
return q.promise;
16+
},
17+
18+
setKeepScreenOn: function (bool) {
19+
var q = $q.defer();
20+
q.resolve('OK');
21+
return q.promise;
22+
}
23+
};
24+
}]);

test/mocks/brightness.spec.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
describe('ngCordovaMocks', function() {
2+
beforeEach(function() {
3+
module('ngCordovaMocks');
4+
});
5+
6+
describe('cordovaBrightness', function () {
7+
var $cordovaBrightness = null;
8+
9+
beforeEach(inject(function (_$cordovaBrightness_) {
10+
$cordovaBrightness = _$cordovaBrightness_;
11+
}));
12+
13+
it('should get the current brightness', function () {
14+
$cordovaBrightness.get().then(function (result) {
15+
expect(result.value).toEqual(100);
16+
});
17+
});
18+
19+
it('should set the current brightness', function () {
20+
$cordovaBrightness.set(50);
21+
22+
var currentBrightness = $cordovaBrightness.get();
23+
$cordovaBrightness.get().then(function (result) {
24+
expect(result.value).toEqual(50);
25+
});
26+
});
27+
});
28+
})

0 commit comments

Comments
 (0)