Commit f4994b8d authored by Donald Cook's avatar Donald Cook

Updated getLockVersion to be more explicit and applied suggestions

Apply suggestion to spec/frontend/autosave_spec.js

Apply suggestion to spec/frontend/autosave_spec.js
parent b9374c25
...@@ -42,7 +42,7 @@ export default class Autosave { ...@@ -42,7 +42,7 @@ export default class Autosave {
} }
} }
getLockVersion() { getSavedLockVersion() {
if (!this.isLocalStorageAvailable) return; if (!this.isLocalStorageAvailable) return;
return window.localStorage.getItem(this.lockVersionKey); return window.localStorage.getItem(this.lockVersionKey);
} }
......
...@@ -105,7 +105,7 @@ describe('Autosave', () => { ...@@ -105,7 +105,7 @@ describe('Autosave', () => {
}); });
}); });
describe('getLockVersion', () => { describe('getSavedLockVersion', () => {
beforeEach(() => { beforeEach(() => {
autosave = { autosave = {
field, field,
...@@ -118,7 +118,7 @@ describe('Autosave', () => { ...@@ -118,7 +118,7 @@ describe('Autosave', () => {
beforeEach(() => { beforeEach(() => {
autosave.isLocalStorageAvailable = false; autosave.isLocalStorageAvailable = false;
Autosave.prototype.getLockVersion.call(autosave); Autosave.prototype.getSavedLockVersion.call(autosave);
}); });
it('should not call .getItem', () => { it('should not call .getItem', () => {
...@@ -132,7 +132,7 @@ describe('Autosave', () => { ...@@ -132,7 +132,7 @@ describe('Autosave', () => {
}); });
it('should call .getItem', () => { it('should call .getItem', () => {
Autosave.prototype.getLockVersion.call(autosave); Autosave.prototype.getSavedLockVersion.call(autosave);
expect(window.localStorage.getItem).toHaveBeenCalledWith(lockVersionKey); expect(window.localStorage.getItem).toHaveBeenCalledWith(lockVersionKey);
}); });
...@@ -178,8 +178,8 @@ describe('Autosave', () => { ...@@ -178,8 +178,8 @@ describe('Autosave', () => {
key, key,
lockVersionKey, lockVersionKey,
lockVersion, lockVersion,
isLocalStorageAvailable: true,
}; };
autosave.isLocalStorageAvailable = true;
}); });
describe('lockVersion is valid', () => { describe('lockVersion is valid', () => {
...@@ -199,11 +199,14 @@ describe('Autosave', () => { ...@@ -199,11 +199,14 @@ describe('Autosave', () => {
}); });
describe('lockVersion is invalid', () => { describe('lockVersion is invalid', () => {
it('should only call .setItem once', () => { it('should not call .setItem with lockVersion', () => {
delete autosave.lockVersion; delete autosave.lockVersion;
Autosave.prototype.save.call(autosave); Autosave.prototype.save.call(autosave);
expect(window.localStorage.setItem).toHaveBeenCalledTimes(1); expect(window.localStorage.setItem).not.toHaveBeenCalledWith(
lockVersionKey,
autosave.lockVersion,
);
}); });
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment