// import { TestBed } from '@angular/core/testing';

// import { base64 } from "rfc4648";
// import { LocalStorageData, LocalStorageService, LocalStorageInterface } from './local-storage.service';

// fdescribe('LocalStorageService', () => {
//   let localStorageService: LocalStorageService;


//   let localStorageData: LocalStorageData = {
//     client_session_key: window.crypto.getRandomValues(new Uint8Array(16)),
//     master_key: window.crypto.getRandomValues(new Uint8Array(32)),
//     encrypting_secret_rsa: window.crypto.getRandomValues(new Uint8Array(1235)),
//     encrypting_secret_ec: window.crypto.getRandomValues(new Uint8Array(48)),
//     signing_secret_ec: window.crypto.getRandomValues(new Uint8Array(48))
//   };

//   let server_session_key = window.crypto.getRandomValues(new Uint8Array(16));


//   /**
//     * localStorage implementation for test
//   */
//  class MockLocalStorage implements LocalStorageInterface{
//     private storage = {};

//     public setItem(key, value:string) {
//       this.storage[key] = value || '';
//     }

//     public getItem(key) {
//       return key in this.storage ? this.storage[key] : null;
//     }

//     removeItem(key) {
//       delete this.storage[key];
//     }
//     get length() {
//       return Object.keys(this.storage).length;
//     }
//     key(i) {
//       const keys = Object.keys(this.storage);
//       return keys[i] || null;
//     }
//     public clear(){
//       this.storage = {};
//       return true;
//     }

//   }

//   let storageMock: MockLocalStorage;


//   beforeEach(() => {
//     TestBed.configureTestingModule({});
//     storageMock = new MockLocalStorage();
//     localStorageService = new LocalStorageService(storageMock)
//   });


//   // test all used function (setItem, getItem, clear)
//   it('mocked localStorage should return null with non-saved data', ()=>{
//     expect(storageMock.getItem('test') === null).toBeTrue();
//   });

//   it('mocked localStorage should save/load', ()=>{
//     storageMock.setItem('test', 'example');

//     expect(storageMock.getItem('test') === 'example').toBeTrue();
//   });

//   it('mocked localStorage should clear', ()=>{
//     storageMock.setItem('test', 'example');
//     storageMock.clear();

//     expect(storageMock.getItem('test') === null).toBeTrue();
//   });

//   it('mocked localStorage should save/load different values', ()=>{
//     storageMock.setItem('test', 'example');
//     storageMock.setItem('test2', 'example2');

//     expect(storageMock.getItem('test') === 'example' && storageMock.getItem('test2') === 'example2').toBeTrue();
//   });


//   // now we can test the service with a working localStorage mock
//   it('it should save into the localstorage', (done) => {

//     localStorageService.save(server_session_key, localStorageData).then(()=>{
//         for(let key in localStorageData){
//             expect(storageMock.getItem(key) !== null).toBeTrue();
//         }
//         done();
//     });

//   });

//   it('it should save/load from localstorage', (done) => {

//     localStorageService.save(server_session_key, localStorageData).then(()=>{
        
//       let loadedPromise = localStorageService.load(server_session_key);
        
//       expect(loadedPromise !== null).toBeTrue();
  
//       loadedPromise.then((loadedData)=>{
//           for(let key in localStorageData){
//               expect(base64.stringify(loadedData[key]) === base64.stringify(localStorageData[key])).toBeTrue();
//           }
//           done();
//       });
//     });

//   });

//   it('reset should work', () => {
//     storageMock.setItem('test', 'ex');
//     localStorageService.reset();
//     expect(storageMock.getItem('test') === null).toBeTrue();
//   });

// });
