Skip to content

Commit

Permalink
storage: Minor test improvements (#26929)
Browse files Browse the repository at this point in the history
Expect console errors.
  • Loading branch information
mdmower committed Feb 24, 2020
1 parent 4852ed2 commit 45f8fbb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/unit/test-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ describes.sandboxed('Storage', {}, env => {
});

it('should recover from binding failure', () => {
expectAsyncConsoleError(/Failed to load store/);
bindingMock
.expects('loadBlob')
.withExactArgs('https://acme.com')
Expand All @@ -193,6 +194,7 @@ describes.sandboxed('Storage', {}, env => {
});

it('should recover from binding error', () => {
expectAsyncConsoleError(/Failed to load store/);
bindingMock
.expects('loadBlob')
.withExactArgs('https://acme.com')
Expand Down Expand Up @@ -499,7 +501,7 @@ describes.sandboxed('LocalStorageBinding', {}, env => {
expect(errorSpy).to.have.not.been.called;

delete windowApi.localStorage;
new LocalStorageBinding(windowApi);
allowConsoleError(() => new LocalStorageBinding(windowApi));
expect(errorSpy).to.be.calledOnce;
expect(errorSpy.args[0][1].message).to.match(/localStorage not supported/);
});
Expand Down Expand Up @@ -564,6 +566,7 @@ describes.sandboxed('LocalStorageBinding', {}, env => {
});

it('should bypass loading from localStorage if getItem throws', () => {
expectAsyncConsoleError(/localStorage not supported/);
localStorageMock
.expects('getItem')
.throws(new Error('unknown'))
Expand Down Expand Up @@ -626,6 +629,7 @@ describes.sandboxed('LocalStorageBinding', {}, env => {
});

it('should bypass saving to localStorage if getItem throws', () => {
expectAsyncConsoleError(/localStorage not supported/);
const setItemSpy = env.sandbox.spy(windowApi.localStorage, 'setItem');

localStorageMock
Expand Down

0 comments on commit 45f8fbb

Please sign in to comment.