ng-local-storage-service
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -20,3 +20,4 @@ { | ||
"homepage": "https://github.com/justinsa/angular-local-storage-service", | ||
"main": "./angular-local-storage-service.js", | ||
"license": "MIT", | ||
"main": "./ng-local-storage-service.js", | ||
"ignore": [ | ||
@@ -23,0 +24,0 @@ ".jshintrc", |
{ | ||
"name": "ng-local-storage-service", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"author": "Justin Saunders (https://github.com/justinsa)", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -11,3 +11,3 @@ [![Bower Version](https://img.shields.io/bower/v/ng-local-storage-service.svg)](https://github.com/justinsa/angular-local-storage-service) | ||
* AngularJS - http://angularjs.org | ||
* Angular Cookies - ngCookies | ||
* Angular Cookies - ngCookies - Only required if ```cookieFallback``` is enabled. | ||
@@ -25,3 +25,3 @@ ##Features | ||
```JAVASCRIPT | ||
var app = angular.module('yourApp', ['local.storage']); | ||
var app = angular.module('yourApp', ['local-storage.service']); | ||
``` | ||
@@ -28,0 +28,0 @@ 2. Inject $store as a parameter in declarations that require it: |
65
tests.js
@@ -6,3 +6,3 @@ /* globals angular, beforeEach, describe, module, inject, it, sinon */ | ||
describe('default settings', function() { | ||
beforeEach(module('local.storage')); | ||
beforeEach(module('local-storage.service')); | ||
@@ -24,3 +24,3 @@ it('should set cookieFallback to true', | ||
beforeEach( | ||
module('local.storage', function ($storeProvider) { | ||
module('local-storage.service', function ($storeProvider) { | ||
$storeProvider.configure({ | ||
@@ -48,3 +48,3 @@ cookieFallback: false, | ||
describe('$get', function() { | ||
beforeEach(module('local.storage')); | ||
beforeEach(module('local-storage.service')); | ||
@@ -81,14 +81,14 @@ it('should have a list of functions', | ||
it('should store info in the cookie store if the environment is not supported', | ||
it('should store info in the cookie store if the environment is not supported', function() { | ||
module('ngCookies'); | ||
inject(function ($store, $cookieStore) { | ||
sinon.spy($cookieStore, 'put'); | ||
$store.setSupported(false); | ||
var result = $store.set('foo', 'bar'); | ||
$store.set('foo', 'bar').should.equal('bar'); | ||
$cookieStore.put.calledOnce.should.be.true; // jshint ignore:line | ||
result.should.equal('bar'); | ||
}) | ||
); | ||
}); | ||
}); | ||
it('should store info in the memStorage if the environment is not supported and cookie fallback is disabled', function() { | ||
module('local.storage', function ($storeProvider) { | ||
module('local-storage.service', function ($storeProvider) { | ||
$storeProvider.configure({cookieFallback: false}); | ||
@@ -106,3 +106,3 @@ }); | ||
describe('get', function() { | ||
beforeEach(module('local.storage')); | ||
beforeEach(module('local-storage.service')); | ||
@@ -116,12 +116,17 @@ it('should return the value from the store', | ||
it('should return the value from the cookie store if the environment is not supported', | ||
inject(function ($store) { | ||
it('should return the value from the cookie store if the environment is not supported', function() { | ||
module('ngCookies'); | ||
inject(function ($store, $cookieStore) { | ||
sinon.spy($cookieStore, 'put'); | ||
sinon.spy($cookieStore, 'get'); | ||
$store.setSupported(false); | ||
$store.set('foo', 'bar'); | ||
$store.get('foo').should.equal('bar'); | ||
}) | ||
); | ||
$cookieStore.put.calledOnce.should.be.true; // jshint ignore:line | ||
$cookieStore.get.calledOnce.should.be.true; // jshint ignore:line | ||
}); | ||
}); | ||
it('should return the value from the memStorage if the environment is not supported and cookie fallback is disabled', function() { | ||
module('local.storage', function ($storeProvider) { | ||
module('local-storage.service', function ($storeProvider) { | ||
$storeProvider.configure({cookieFallback: false}); | ||
@@ -139,3 +144,3 @@ }); | ||
describe('remove', function() { | ||
beforeEach(module('local.storage')); | ||
beforeEach(module('local-storage.service')); | ||
@@ -150,3 +155,4 @@ it('should remove the value from the store', | ||
it('should remove the value from the cookie store if the environment is not supported', | ||
it('should remove the value from the cookie store if the environment is not supported', function() { | ||
module('ngCookies'); | ||
inject(function ($store, $cookieStore) { | ||
@@ -157,7 +163,7 @@ $store.setSupported(false); | ||
$cookieStore.remove.calledOnce.should.be.true; // jshint ignore:line | ||
}) | ||
); | ||
}); | ||
}); | ||
it('should remove the value from the memStorage if the environment is not supported and cookie fallback is disabled', function() { | ||
module('local.storage', function ($storeProvider) { | ||
module('local-storage.service', function ($storeProvider) { | ||
$storeProvider.configure({cookieFallback: false}); | ||
@@ -176,3 +182,3 @@ }); | ||
describe('bind', function() { | ||
beforeEach(module('local.storage')); | ||
beforeEach(module('local-storage.service')); | ||
@@ -199,3 +205,3 @@ it('should add a watch to a scope', | ||
describe('unbind', function() { | ||
beforeEach(module('local.storage')); | ||
beforeEach(module('local-storage.service')); | ||
@@ -227,3 +233,3 @@ it('should empty the watcher', | ||
describe('has', function() { | ||
beforeEach(module('local.storage')); | ||
beforeEach(module('local-storage.service')); | ||
@@ -237,3 +243,3 @@ it('should return false if the key is not in the store', | ||
it('should return true if the key in the store', | ||
it('should return true if the key is in the store', | ||
inject(function ($store) { | ||
@@ -247,3 +253,3 @@ $store.set('foo', 'bar'); | ||
describe('clear', function() { | ||
beforeEach(module('local.storage')); | ||
beforeEach(module('local-storage.service')); | ||
@@ -262,3 +268,4 @@ it('should remove everything if the environment is supported', | ||
it('should not remove anything if cookie fallback is enabled', | ||
it('should not remove anything if cookie fallback is enabled', function() { | ||
module('ngCookies'); | ||
inject(function ($store) { | ||
@@ -273,7 +280,7 @@ $store.setSupported(false); | ||
$store.has('baz').should.be.true; // jshint ignore:line | ||
}) | ||
); | ||
}); | ||
}); | ||
it('should create a new memStorage object if environment is not supported and cookie fallback is disabled', function() { | ||
module('local.storage', function ($storeProvider) { | ||
module('local-storage.service', function ($storeProvider) { | ||
$storeProvider.configure({cookieFallback: false}); | ||
@@ -280,0 +287,0 @@ }); |
Sorry, the diff of this file is not supported yet
29991
486