The goog.testing.MockStorage Class

goog.testing.MockStorage()

A JS storage instance, implementing the HMTL5 Storage interface. See http://www.w3.org/TR/webstorage/ for details.

.clear()

Clears the storage.

.getItem(key)

Gets an item from the storage. The item returned is the "structured clone" of the value from setItem. In practice this means it's the value cast to a string.

key {string}
Storage key.
returns {?string}
Storage value for key; null if does not exist.

.key(index)

Returns the key at the given index.

index {number}
The index for the key.
returns {?string}
Key at the given index, null if not found.

.length {number}

The number of elements in the storage.

.removeItem(key)

Removes and item from the storage.

key {string}
Storage key.

.setItem(key, value)

Sets an item to the storage.

key {string}
Storage key.
value {*}
Storage value. Must be convertible to string.