All tests for secure storage service on desktop.
This commit is contained in:
parent
da9559433f
commit
f4642b1953
1 changed files with 54 additions and 1 deletions
|
|
@ -17,7 +17,6 @@ describe('secureStorageService on desktop', function(){
|
||||||
|
|
||||||
module(function($provide) {
|
module(function($provide) {
|
||||||
$provide.value('desktopSecureStorageService', desktopSss);
|
$provide.value('desktopSecureStorageService', desktopSss);
|
||||||
//$provide.value('$log', log); // Handy for debugging test failures
|
|
||||||
$provide.value('platformInfo', platformInfoStub);
|
$provide.value('platformInfo', platformInfoStub);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -27,6 +26,24 @@ describe('secureStorageService on desktop', function(){
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('get fails', function() {
|
||||||
|
var error, key, result;
|
||||||
|
|
||||||
|
desktopSss.get.and.callFake(function(k, cb){
|
||||||
|
key = k;
|
||||||
|
cb(new Error('Get error.'), null);
|
||||||
|
});
|
||||||
|
|
||||||
|
sss.get('a1234', function(e, res) {
|
||||||
|
error = e;
|
||||||
|
result = res;
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(error.message).toBe('Get error.');
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
expect(key).toBe('a1234');
|
||||||
|
});
|
||||||
|
|
||||||
it('get succeeds', function() {
|
it('get succeeds', function() {
|
||||||
var error, key, result;
|
var error, key, result;
|
||||||
|
|
||||||
|
|
@ -45,5 +62,41 @@ describe('secureStorageService on desktop', function(){
|
||||||
expect(key).toBe('a123');
|
expect(key).toBe('a123');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('set fails', function() {
|
||||||
|
var error, key, value;
|
||||||
|
|
||||||
|
desktopSss.set.and.callFake(function(k, v, cb){
|
||||||
|
key = k;
|
||||||
|
value = v;
|
||||||
|
cb(new Error('Set error.'));
|
||||||
|
});
|
||||||
|
|
||||||
|
sss.set('a12345', 'The value 1.', function(e) {
|
||||||
|
error = e;
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(error.message).toBe('Set error.');
|
||||||
|
expect(key).toBe('a12345');
|
||||||
|
expect(value).toBe('The value 1.');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('set succeeds', function() {
|
||||||
|
var error, key, value;
|
||||||
|
|
||||||
|
desktopSss.set.and.callFake(function(k, v, cb){
|
||||||
|
key = k;
|
||||||
|
value = v;
|
||||||
|
cb(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
sss.set('ab123', 'The value 2.', function(e) {
|
||||||
|
error = e;
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(error).toBeFalsy();
|
||||||
|
expect(key).toBe('ab123');
|
||||||
|
expect(value).toBe('The value 2.')
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue