-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from Rise-Vision/fix/ls-out-quota-issue
Implemented ability to tell which storage, local or session to be used
- Loading branch information
Showing
10 changed files
with
386 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "rise-data", | ||
"version": "1.3.7", | ||
"version": "1.3.8", | ||
"authors": [ | ||
"Rise Vision" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> | ||
<title>rise-data</title> | ||
|
||
<script src="../../bower_components/webcomponentsjs/webcomponents.min.js"></script> | ||
<script src="../../bower_components/web-component-tester/browser.js"></script> | ||
|
||
<link rel="import" href="../../rise-data.html"> | ||
</head> | ||
<body> | ||
|
||
<rise-data id="request"></rise-data> | ||
|
||
<script src="../data/sheet.js"></script> | ||
<script src="../../node_modules/widget-tester/mocks/localStorage-mock.js"></script> | ||
<script src="../../node_modules/widget-tester/mocks/sessionStorage-mock.js"></script> | ||
|
||
<script> | ||
/* global sinon, suite, test, assert, suiteSetup, suiteTeardown, setup, teardown, sheetKey, sheetData */ | ||
|
||
var dataRequest = document.querySelector( "#request" ); | ||
|
||
// mock logger getting display id and force RC running | ||
sinon.stub( dataRequest.$.logger.$.displayId, "generateRequest", function() { | ||
dataRequest.$.logger._onDisplayIdResponse( null, { response: { displayId: "abc123" } } ); | ||
} ); | ||
|
||
// mock ping and force RC running | ||
sinon.stub( dataRequest.$.ping, "generateRequest", function() { | ||
dataRequest._handlePingResponse( null, { response: { name: "rise-cache-v2", version: "0.0.0" } } ); | ||
} ); | ||
|
||
suite( "sessionStorage when RC is running", function() { | ||
suiteSetup( function() { | ||
dataRequest.endpoint = "spreadsheets" | ||
} ); | ||
|
||
suiteTeardown( function() { | ||
dataRequest.$.logger.$.displayId.generateRequest.restore(); | ||
dataRequest.$.ping.generateRequest.restore(); | ||
} ); | ||
|
||
suite( "RC running", function() { | ||
|
||
test( "should not save to session or local storage even though it saves to RC", function() { | ||
|
||
var sessionStorageSetItemStub = sinon.stub( sessionStorage, "setItem" ), | ||
localStorageSetItemStub = sinon.stub( localStorage, "setItem" ); | ||
|
||
dataRequest.saveItem( sheetKey, { results: sheetData.values } ); | ||
|
||
assert.isFalse( sessionStorageSetItemStub.called ); | ||
assert.isFalse( localStorageSetItemStub.called ); | ||
|
||
} ); | ||
} ); | ||
|
||
suite( "RC fail to get", function() { | ||
|
||
setup( function() { | ||
// mock ping and force RC running | ||
sinon.stub( dataRequest.$.cache, "generateRequest", function() { | ||
var resp = { request: { status: 404 } }; | ||
|
||
dataRequest._handleCacheError( null, resp ); | ||
} ); | ||
|
||
sessionStorage.setItem( sheetKey, JSON.stringify( { results: sheetData.values } ) ); | ||
localStorage.setItem( sheetKey, JSON.stringify( { results: sheetData.values } ) ); | ||
} ); | ||
|
||
teardown( function() { | ||
window.sessionStorageError = false; | ||
sessionStorage.removeItem( sheetKey ); | ||
|
||
window.localStorageError = false; | ||
localStorage.removeItem( sheetKey ); | ||
dataRequest.$.cache.generateRequest.restore(); | ||
} ); | ||
|
||
test( "should not get data from session or local storage if it fails to get from RC", function() { | ||
|
||
var sessionStorageGetItemStub = sinon.stub( sessionStorage, "getItem", function() { | ||
return JSON.stringify( { results: sheetData.values } ); | ||
} ), | ||
localStorageGetItemStub = sinon.stub( localStorage, "getItem", function() { | ||
return JSON.stringify( { results: sheetData.values } ); | ||
} ); | ||
|
||
dataRequest.getItem( sheetKey, function() {} ); | ||
|
||
assert.isFalse( sessionStorageGetItemStub.called ); | ||
assert.isFalse( localStorageGetItemStub.called ); | ||
|
||
} ); | ||
} ); | ||
|
||
|
||
|
||
} ); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.