-
-
Notifications
You must be signed in to change notification settings - Fork 143
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 #785 from kiskoza/fix-pulsar-updater-skip-version-…
…cache 🐛 ✅ Fix caching for "Dismiss this Version" in pulsar-updater
- Loading branch information
Showing
2 changed files
with
28 additions
and
7 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,20 +1,41 @@ | ||
const cache = require("../src/cache.js"); | ||
|
||
describe("pulsar-updater cache", () => { | ||
beforeEach(() => { | ||
jasmine.useRealClock(); | ||
}); | ||
|
||
it("returns key for path", () => { | ||
let key = cache.cacheKeyForPath("test"); | ||
expect(key).toBe("pulsar-updater:test"); | ||
}); | ||
|
||
it("returns expired properly according to date", () => { | ||
let expiry = cache.isItemExpired({ createdOn: Date.now() }); | ||
it("returns not expired properly according to date", () => { | ||
let expiry = cache.isItemExpired({ createdOn: Date.now() }, 'some-key'); | ||
expect(expiry).toBe(false); | ||
}); | ||
|
||
it("returns not expired if offline", () => { | ||
spyOn(cache, "online").andReturn(true); | ||
it("returns expired properly according to date", () => { | ||
let expiry = cache.isItemExpired({ createdOn: 0 }, 'some-key'); | ||
expect(expiry).toBe(true); | ||
}); | ||
|
||
let expiry = cache.isItemExpired({ createdOn: 0 }); | ||
it("returns not expired properly for last-update-check", () => { | ||
let expiry = cache.isItemExpired({ createdOn: 0 }, 'last-update-check'); | ||
expect(expiry).toBe(false); | ||
}) | ||
}); | ||
|
||
if(jasmine.version_.major > 1) { | ||
// TODO: The current version right now is 1.3.1 of jasmine-node | ||
// https://github.com/kevinsawicki/jasmine-node | ||
// | ||
// This is an unmaintained package that tried to implement jasmine for node, | ||
// however we have an official jasmine implementation since then | ||
it("returns not expired if offline", () => { | ||
spyOnProperty(window.navigator, 'onLine').and.returnValue(false); | ||
|
||
let expiry = cache.isItemExpired({ createdOn: 0 }, 'some-key'); | ||
expect(expiry).toBe(false); | ||
}); | ||
} | ||
}); |
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