From 3649d5c54a11178ac0aa740467d66126330e6d47 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Mon, 7 Aug 2017 17:21:25 -0300 Subject: [PATCH] tests --- src/providers/persistence/persistence.spec.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/providers/persistence/persistence.spec.ts b/src/providers/persistence/persistence.spec.ts index a3143aa4f..96b40d169 100644 --- a/src/providers/persistence/persistence.spec.ts +++ b/src/providers/persistence/persistence.spec.ts @@ -1,6 +1,6 @@ import { TestBed, inject } from '@angular/core/testing'; import { PersistenceProvider } from './persistence'; -import { IStorage, ISTORAGE } from './storage/istorage'; +import { IStorage, ISTORAGE, KeyAlreadyExistsError } from './storage/istorage'; import { RamStorage } from './storage/ram-storage'; describe('Storage Service', () => { @@ -26,5 +26,14 @@ describe('Storage Service', () => { }); }); })); + it('should fail to create a profile when one already exists', inject([PersistenceProvider], (service: PersistenceProvider) => { + var p = { name: 'My profile' }; + service.storeNewProfile(p, (err) => { + expect(err).toBeNull; + service.storeNewProfile(p, (err) => { + expect(err.message).toEqual('Key already exists'); + }); + }); + })); }); }); \ No newline at end of file