]> git.proxmox.com Git - extjs.git/blob - extjs/packages/core/test/specs/data/proxy/LocalStorage.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / core / test / specs / data / proxy / LocalStorage.js
1 describe("Ext.data.proxy.LocalStorage", function() {
2 var proxy;
3
4 if (Ext.supports.LocalStorage) {
5 beforeEach(function() {
6 Ext.ClassManager.enableNamespaceParseCache = false;
7 proxy = new Ext.data.proxy.LocalStorage({id: 1});
8 });
9
10 afterEach(function() {
11 Ext.ClassManager.enableNamespaceParseCache = true;
12 });
13
14 describe("instantiation", function() {
15 it("should extend Ext.data.proxy.WebStorage", function() {
16 expect(proxy.superclass).toEqual(Ext.data.proxy.WebStorage.prototype);
17 });
18 });
19
20 describe("methods", function() {
21 describe("getStorageObject", function() {
22 it("should return localStorage object", function() {
23 // IE8 throw Class doesn't support Automation when comparing localStorage to itself (or sessionStorage)
24 var automationBug = false;
25 try {
26 localStorage === localStorage;
27 } catch(e) {
28 automationBug = true;
29 }
30 if (!automationBug) {
31 expect(proxy.getStorageObject()).toEqual(localStorage);
32 } else {
33 var storageObject = proxy.getStorageObject();
34 expect(window.localStorage.setItem === storageObject.setItem).toBe(true);
35 }
36 });
37 });
38 });
39 } else {
40 describe("instantiation", function() {
41 it("should throw an error", function() {
42 expect(function() {
43 new Ext.data.proxy.LocalStorage({id: 1});
44 }).toRaiseExtError("Local Storage is not supported in this browser, please use another type of data proxy");
45 });
46 });
47 }
48 });