@@ -15,7 +15,7 @@ describe("WebStorageStateStore", function() {
1515 beforeEach ( function ( ) {
1616 prefix = "" ;
1717 store = new InMemoryWebStorage ( ) ;
18- subject = new WebStorageStateStore ( { prefix :prefix , store :store } ) ;
18+ subject = new WebStorageStateStore ( { prefix : prefix , store : store } ) ;
1919 } ) ;
2020
2121 describe ( "set" , function ( ) {
@@ -25,17 +25,17 @@ describe("WebStorageStateStore", function() {
2525 } ) ;
2626
2727 it ( "should store item" , function ( done ) {
28- subject . set ( "key" , "value" ) . then ( ( ) => {
28+ subject . set ( "key" , "value" ) . then ( ( ) => {
2929 store . getItem ( "key" ) . should . equal ( "value" ) ;
3030 done ( ) ;
3131 } )
3232 } ) ;
33-
34- it ( "should use prefix if specified" , function ( ) {
33+
34+ it ( "should use prefix if specified" , function ( ) {
3535 prefix = "foo." ;
36- subject = new WebStorageStateStore ( { prefix :prefix , store :store } ) ;
36+ subject = new WebStorageStateStore ( { prefix : prefix , store : store } ) ;
3737
38- subject . set ( "key" , "value" ) . then ( ( ) => {
38+ subject . set ( "key" , "value" ) . then ( ( ) => {
3939 store . getItem ( prefix + "key" ) . should . equal ( "value" ) ;
4040 done ( ) ;
4141 } )
@@ -74,9 +74,9 @@ describe("WebStorageStateStore", function() {
7474 } ) ;
7575 } ) ;
7676
77- it ( "should use prefix if specified" , function ( done ) {
77+ it ( "should use prefix if specified" , function ( done ) {
7878 prefix = "foo." ;
79- subject = new WebStorageStateStore ( { prefix :prefix , store :store } ) ;
79+ subject = new WebStorageStateStore ( { prefix : prefix , store : store } ) ;
8080
8181 store . setItem ( "foo.key" , "value" ) ;
8282
@@ -88,4 +88,65 @@ describe("WebStorageStateStore", function() {
8888
8989 } ) ;
9090
91+ describe ( "get" , function ( ) {
92+
93+ it ( "should return a promise" , function ( ) {
94+ subject . get ( "key" ) . should . be . instanceof ( Promise ) ;
95+ } ) ;
96+
97+ it ( "should return value if exists" , function ( done ) {
98+ store . setItem ( "key" , "test" ) ;
99+
100+ subject . get ( "key" ) . then ( value => {
101+ value . should . equal ( 'test' ) ;
102+ done ( ) ;
103+ } ) ;
104+ } ) ;
105+
106+ it ( "should return undefined if doesn't exist" , function ( done ) {
107+ subject . get ( "key" ) . then ( value => {
108+ expect ( value ) . to . be . undefined ;
109+ done ( ) ;
110+ } ) ;
111+ } ) ;
112+
113+ it ( "should use prefix if specified" , function ( done ) {
114+ prefix = "foo." ;
115+ subject = new WebStorageStateStore ( { prefix : prefix , store : store } ) ;
116+
117+ store . setItem ( "foo.key" , "value" ) ;
118+
119+ subject . get ( "key" ) . then ( item => {
120+ item . should . equal ( "value" ) ;
121+ done ( ) ;
122+ } ) ;
123+ } ) ;
124+
125+ } ) ;
126+
127+ describe ( "getAllKeys" , function ( ) {
128+
129+ it ( "should return a promise" , function ( ) {
130+ subject . getAllKeys ( ) . should . be . instanceof ( Promise ) ;
131+ } ) ;
132+
133+ it ( "should return keys" , function ( done ) {
134+ store . setItem ( "key1" , "test" ) ;
135+ store . setItem ( "key2" , "test" ) ;
136+
137+ subject . getAllKeys ( ) . then ( keys => {
138+ keys . should . deep . equal ( [ "key1" , "key2" ] ) ;
139+ done ( ) ;
140+ } ) ;
141+ } ) ;
142+
143+ it ( "should return empty keys when empty" , function ( done ) {
144+ subject . getAllKeys ( ) . then ( keys => {
145+ keys . should . deep . equal ( [ ] ) ;
146+ done ( ) ;
147+ } ) ;
148+ } ) ;
149+
150+ } ) ;
151+
91152} ) ;
0 commit comments