diff --git a/src/app/app.module.ts b/src/app/app.module.ts index a3f3bdfb3..a4f90e359 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -22,7 +22,7 @@ import { StatusBar } from '@ionic-native/status-bar'; import { SplashScreen } from '@ionic-native/splash-screen'; import { WalletProvider } from '../providers/wallet/wallet'; -import { StorageProvider } from '../providers/storage/storage'; +import { PersistenceProvider } from '../providers/persistence/persistence'; import { AppProvider } from '../providers/app/app'; import { PlatformProvider } from '../providers/platform/platform'; @@ -70,7 +70,7 @@ export function createTranslateLoader(http: Http) { SplashScreen, { provide: ErrorHandler, useClass: IonicErrorHandler }, WalletProvider, - StorageProvider, + PersistenceProvider, AppProvider, PlatformProvider ] diff --git a/src/providers/storage/storage.spec.ts b/src/providers/persistence/persistence.spec.ts similarity index 62% rename from src/providers/storage/storage.spec.ts rename to src/providers/persistence/persistence.spec.ts index 7db3d264e..a3143aa4f 100644 --- a/src/providers/storage/storage.spec.ts +++ b/src/providers/persistence/persistence.spec.ts @@ -1,22 +1,21 @@ import { TestBed, inject } from '@angular/core/testing'; -import { StorageProvider } from './storage'; -import { LocalStorage } from './local-storage'; -import { IStorage, ISTORAGE } from './istorage'; -import * as Mocks from '../../mocks'; +import { PersistenceProvider } from './persistence'; +import { IStorage, ISTORAGE } from './storage/istorage'; +import { RamStorage } from './storage/ram-storage'; describe('Storage Service', () => { - let storage: IStorage = new Mocks.StorageMock(); + let storage: IStorage = new RamStorage(); beforeEach(() => { TestBed.configureTestingModule({ providers: [ - StorageProvider, + PersistenceProvider, { provide: ISTORAGE, useValue: storage }, ] }); }); describe('#profile', () => { - it('should correctly perform a profile roundtrip', inject([StorageProvider], (service: StorageProvider) => { + it('should correctly perform a profile roundtrip', inject([PersistenceProvider], (service: PersistenceProvider) => { var p = { name: 'My profile' }; service.storeNewProfile(p, (err) => { expect(err).toBeNull; diff --git a/src/providers/storage/storage.ts b/src/providers/persistence/persistence.ts similarity index 89% rename from src/providers/storage/storage.ts rename to src/providers/persistence/persistence.ts index 351107d62..fa35dbd47 100644 --- a/src/providers/storage/storage.ts +++ b/src/providers/persistence/persistence.ts @@ -1,9 +1,9 @@ import { Injectable } from '@angular/core'; import { InjectionToken, Inject } from '@angular/core'; -import { IStorage, ISTORAGE } from './istorage'; +import { IStorage, ISTORAGE } from './storage/istorage'; @Injectable() -export class StorageProvider { +export class PersistenceProvider { constructor( @Inject(ISTORAGE) private storage: IStorage) { } diff --git a/src/providers/storage/istorage.ts b/src/providers/persistence/storage/istorage.ts similarity index 100% rename from src/providers/storage/istorage.ts rename to src/providers/persistence/storage/istorage.ts diff --git a/src/providers/storage/local-storage.ts b/src/providers/persistence/storage/local-storage.ts similarity index 95% rename from src/providers/storage/local-storage.ts rename to src/providers/persistence/storage/local-storage.ts index b0b995d71..e8cc9035f 100644 --- a/src/providers/storage/local-storage.ts +++ b/src/providers/persistence/storage/local-storage.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { PlatformProvider } from '../platform/platform'; +import { PlatformProvider } from '../../platform/platform'; import { Logger } from '@nsalaun/ng-logger'; import * as _ from 'lodash'; diff --git a/src/mocks.ts b/src/providers/persistence/storage/ram-storage.ts similarity index 81% rename from src/mocks.ts rename to src/providers/persistence/storage/ram-storage.ts index a7e78df40..9c83b15f2 100644 --- a/src/mocks.ts +++ b/src/providers/persistence/storage/ram-storage.ts @@ -1,6 +1,6 @@ -import { IStorage, KeyAlreadyExistsError } from './providers/storage/istorage'; +import { IStorage, KeyAlreadyExistsError } from './istorage'; -export class StorageMock implements IStorage { +export class RamStorage implements IStorage { hash = {}; get(k: string, cb: (err: Error, v: string) => void) {