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

Commit 8e2daa5

Browse files
committed
Added brightness mock
1 parent a5acca1 commit 8e2daa5

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
var currentBrightness = $cordovaBrightness.get();
15+
expect(currentBrightness).toEqual(100);
16+
});
17+
18+
it('should set the current brightness', function () {
19+
$cordovaBrightness.set(50);
20+
21+
var currentBrightness = $cordovaBrightness.get();
22+
expect(currentBrightness).toEqual(50);
23+
});
24+
});
25+
})

0 commit comments

Comments
 (0)