* fix: eslint operator-linebreak issue * fix: eslint quotes issue * fix: react jsx indent and props issues * fix: eslint trailing spaces issues * fix: eslint line around directives issue * fix: eslint semi rule * fix: eslint newline per chain rule * fix: eslint space infix ops rule * fix: eslint space-in-parens issue * fix: eslint space before function paren issue * fix: eslint space before blocks issue * fix: eslint arrow body style issue * fix: eslint dot-location issue * fix: eslint quotes issue * fix: eslint quote props issue * fix: eslint operator assignment issue * fix: eslint new line after import issue * fix: indent issues * fix: operator assignment issue * fix: all autofixable eslint issues * fix: all react related fixable issues * fix: autofixable eslint issues * chore: remove all template literals * fix: remaining autofixable issues * chore: apply amnesty on all existing issues * fix: failing xss-lint issues * refactor: apply amnesty on remaining issues * refactor: apply amnesty on new issues * fix: remove file level suppressions * refactor: apply amnesty on new issues
87 lines
3.3 KiB
JavaScript
87 lines
3.3 KiB
JavaScript
// eslint-disable-next-line no-shadow-restricted-names
|
|
(function(require, define, undefined) {
|
|
require(
|
|
['video/00_video_storage.js'],
|
|
function(VideoStorage) {
|
|
describe('VideoStorage', function() {
|
|
var namespace = 'test_storage',
|
|
id = 'video_id';
|
|
|
|
afterEach(function() {
|
|
VideoStorage(namespace, id).clear();
|
|
});
|
|
|
|
describe('initialize', function() {
|
|
it('with namespace and id', function() {
|
|
var storage = VideoStorage(namespace, id);
|
|
|
|
expect(window[namespace]).toBeDefined();
|
|
expect(window[namespace][id]).toBeDefined();
|
|
});
|
|
|
|
it('without namespace and id', function() {
|
|
spyOn(Number.prototype, 'toString').and.returnValue('0.abcdedg');
|
|
var storage = VideoStorage();
|
|
|
|
expect(window.VideoStorage).toBeDefined();
|
|
expect(window.VideoStorage.abcdedg).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('methods: ', function() {
|
|
var data, storage;
|
|
|
|
beforeEach(function() {
|
|
data = {
|
|
item_2: 'value_2'
|
|
};
|
|
data[id] = {
|
|
item_1: 'value_1'
|
|
};
|
|
|
|
window[namespace] = data;
|
|
storage = VideoStorage(namespace, id);
|
|
});
|
|
|
|
it('setItem', function() {
|
|
var expected = $.extend(true, {}, data, {item_4: 'value_4'});
|
|
|
|
expected[id].item_3 = 'value_3';
|
|
storage.setItem('item_3', 'value_3', true);
|
|
storage.setItem('item_4', 'value_4');
|
|
expect(window[namespace]).toEqual(expected);
|
|
});
|
|
|
|
it('getItem', function() {
|
|
// eslint-disable-next-line no-shadow
|
|
var data = window[namespace],
|
|
getItem = storage.getItem;
|
|
|
|
expect(getItem('item_1', true)).toBe(data[id].item_1);
|
|
expect(getItem('item_2')).toBe(data.item_2);
|
|
expect(getItem('item_3')).toBeUndefined();
|
|
});
|
|
|
|
it('removeItem', function() {
|
|
// eslint-disable-next-line no-shadow
|
|
var data = window[namespace],
|
|
removeItem = storage.removeItem;
|
|
|
|
removeItem('item_1', true);
|
|
removeItem('item_2');
|
|
expect(data[id].item_1).toBeUndefined();
|
|
expect(data.item_2).toBeUndefined();
|
|
});
|
|
|
|
it('clear', function() {
|
|
var expected = {};
|
|
|
|
expected[id] = {};
|
|
storage.clear();
|
|
expect(window[namespace]).toEqual(expected);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}(require, define));
|