feat: 🎸 Update how we store tokens in indexed-db (#2223)
Added logic to make the list tokens stored in indexed DB more granular. I get a hash of the query parameters that will get sent to the controller and use that as the id for the token. This also means extra logic for when a token is invalid as we will need to delete all tokens of the same resource type.
This commit is contained in:
1 parent
6c59baa413
commit
5d32d987bc
13 files changed
+121
-33
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import { hashCode } from 'api/utils/hash-code';
|
||||
import { module, test } from 'qunit';
|
||||
|
||||
module('Unit | Utility | hash-code', function () {
|
||||
test('it hashes', function (assert) {
|
||||
const result = hashCode({ a: 1, b: 2 });
|
||||
assert.ok(result);
|
||||
});
|
||||
|
||||
test('it hashes to same result regardless of object order', function (assert) {
|
||||
const first = hashCode({ a: 1, b: 2, c: 3 });
|
||||
const second = hashCode({ b: 2, c: 3, a: 1 });
|
||||
assert.strictEqual(first, second);
|
||||
});
|
||||
|
||||
test('it hashes to different result if objects are different', function (assert) {
|
||||
const first = hashCode({ a: 1, b: 2, c: 3 });
|
||||
const second = hashCode({ a: '1', b: '2', c: '3' });
|
||||
assert.notStrictEqual(first, second);
|
||||
});
|
||||
|
||||
test('it hashes an empty object', function (assert) {
|
||||
const result = hashCode({});
|
||||
assert.ok(result);
|
||||
});
|
||||
|
||||
test('it hashes null to 0', function (assert) {
|
||||
const result = hashCode(null);
|
||||
assert.strictEqual(result, 0);
|
||||
});
|
||||
|
||||
test('it hashes undefined to 0', function (assert) {
|
||||
const result = hashCode(undefined);
|
||||
assert.strictEqual(result, 0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user