-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Persist): add depth structure #34
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to common storageKey in setStateByKey
@@ -56,45 +85,6 @@ describe("Persist", function() { | |||
location.hash = ""; | |||
sessionStorage.clear(); | |||
}); | |||
it("save number, get number(excludeHash: true)", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed i thnk
const length4 = StorageManager.getStateByKey(CONST_PERSIST_STATE, CONST_DEPTHS).length; | ||
const currentUrl4 = StorageManager.getStateByKey(CONST_PERSIST_STATE, CONST_CURRENT_URL); | ||
|
||
expect(value1).to.be.equals(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Then
test/unit/persist.spec.js
Outdated
expect(length2).to.be.equals(2); | ||
expect(currentUrl2.lastIndexOf("a")).to.be.equals(currentUrl2.length - 1); | ||
|
||
expect(value3).to.be.equals(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think expect(value3).to.be.equals(value1);
also meaningful test.
test/unit/persist.spec.js
Outdated
expect(length3).to.be.equals(2); | ||
expect(currentUrl3.lastIndexOf(pathname)).to.be.equals(currentUrl1.length - pathname.length); | ||
|
||
expect(value4).to.be.equals(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(value3).to.be.equals(value2);
src/Persist.js
Outdated
StorageManager.setStateByKey(CONST_PERSIST_STATE, CONST_CURRENT_URL, currentUrl); | ||
} | ||
} else { | ||
const current = StorageManager.getStateByKey(CONST_PERSIST_STATE, CONST_CURRENT_URL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current
is differ from prevUrl
?
src/utils.js
Outdated
function getUrl() { | ||
return location.href.split("#")[0]; | ||
} | ||
function getKey(name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getStorageKey
would be better.
src/Persist.js
Outdated
@@ -33,28 +104,29 @@ function setRec(obj, path, value) { | |||
class Persist { | |||
static VERSION = "#__VERSION__#"; | |||
static StorageManager = StorageManager; | |||
static url = ""; | |||
static [CONST_CURRENT_URL] = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array is intended?
src/Persist.js
Outdated
StorageManager.reset(CONST_PERSIST_STATE, null); | ||
|
||
Persist.url = ""; | ||
Persist[CONST_CURRENT_URL] = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest
- Persist.url => CURRENT_URL
- Persist.url => LAST_SET_URL
|
||
describe("StorageManager", function() { | ||
describe("reset when initialize", function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Younkue It should be needed
|
||
// Then | ||
expect(isBackForwardNavigated).is.not.ok; | ||
expect(navigationType).is.equals(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test for type 0
#33