123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- import setStorage2 from "../scripts/setStorage2.js";
- const assert = chai.assert;
-
- describe('setStorage2 #es6', function () {
- it('should store key/value arguments. Function is a module', function () {
- setStorage2("c", "d");
- assert.equal("d", window.localStorage.getItem("c"));
- window.localStorage.removeItem("c");
- });
- });
-
-
- describe('setLocalStorage', function () {
- it('should store key/value arguments', function () {
- setLocalStorage("a", "b");
- assert.equal("b", window.localStorage.getItem("a"));
- //chai.expect(window.localStorage.getItem("a")).to.equal("b");
- window.localStorage.removeItem("a");
- });
- it('should has stored key argument', function () {
- setLocalStorage("testkey", "testvalue");
- assert.hasAnyKeys(window.localStorage, 'testkey');
- window.localStorage.removeItem("testkey");
- });
- });
-
-
- describe('getLocalStorageKey', function () {
- it('should return first key', function () {
- assert.equal(window.localStorage.key(0), getLocalStorageKey(0));
- });
- it('should return first key as string value', function () {
- assert.typeOf(window.localStorage.key(0), 'string');
- });
- });
-
-
- describe('getLocalStorageItem', function () {
- it('should return item', function () {
- window.localStorage.setItem("e", "f");
- assert.equal("f", getLocalStorageItem("e"));
- window.localStorage.removeItem("e");
- });
- it('should return item as string value', function () {
- window.localStorage.setItem("g", "h");
- assert.typeOf(getLocalStorageItem("g"), 'string');
- window.localStorage.removeItem("g");
- });
- it('should return item as string value', function () {
- window.localStorage.setItem("myKey2", "myValue2");
- assert.isString(getLocalStorageItem("myKey2"), 'Item is string');
- window.localStorage.removeItem("myKey2");
- });
- });
-
-
- describe('LocalStorage', function () {
- it('should extensible', function () {
- assert.isExtensible(window.localStorage);
- });
- it('should not empty', function () {
- assert.isNotEmpty(window.localStorage);
- });
- it('should empty', function () {
- assert.isEmpty(window.localStorage);
- });
- it('Local Storage should be an object', function () {
- assert.isObject(window.localStorage, 'Yes local storage is an object!');
- });
- it('Local Storage should be ok', function () {
- assert.isOk(window.localStorage, 'Yes local storage is ok!');
- });
- });
-
- describe('deleteLocalStorageItem', function () {
- it('should deleted key=i/value=l', function () {
- window.localStorage.setItem("i", "j");
- deleteLocalStorageItem("i");
- assert.doesNotHaveAnyKeys(window.localStorage, 'i');
- });
- it('Local Storage list should be smaller if key/value pair is deleted', function () {
- window.localStorage.setItem("k", "l");
- var preCount = window.localStorage.length;
- deleteLocalStorageItem("k");
- var postCount = window.localStorage.length;
- assert.operator(postCount, '<', preCount, 'is smaller, ok');
- });
- });
-
-
- describe('getLocalStorageLength', function () {
- it('should return local storage length', function () {
- assert.lengthOf(window.localStorage, getLocalStorageLength());
- });
- });
-
-
- mocha.checkLeaks();
- mocha.run();
|