aboutsummaryrefslogtreecommitdiff
path: root/test/cache-map.test.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-11-29 21:04:27 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-11-29 21:04:27 -0500
commita0a6291db8e2be29c4ed13645c250201b4552b9d (patch)
tree18a0141f0aed7d87e1a1c0cbf1fd86b9de2ba8f4 /test/cache-map.test.js
parent9ed81f25ab7f462546888a4ddd7fcecdf5ea1806 (diff)
Update tests
Diffstat (limited to 'test/cache-map.test.js')
-rw-r--r--test/cache-map.test.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/test/cache-map.test.js b/test/cache-map.test.js
index 9d10a719..3e7def1f 100644
--- a/test/cache-map.test.js
+++ b/test/cache-map.test.js
@@ -19,6 +19,7 @@
import {expect, test} from 'vitest';
import {CacheMap} from '../ext/js/general/cache-map.js';
+/** */
function testConstructor() {
test('constructor', () => {
const data = [
@@ -29,6 +30,7 @@ function testConstructor() {
[true, () => new CacheMap(1.5)],
[true, () => new CacheMap(Number.NaN)],
[true, () => new CacheMap(Number.POSITIVE_INFINITY)],
+ // @ts-ignore - Ignore because it should throw an error
[true, () => new CacheMap('a')]
];
@@ -42,6 +44,7 @@ function testConstructor() {
});
}
+/** */
function testApi() {
test('api', () => {
const data = [
@@ -103,10 +106,10 @@ function testApi() {
const {func, args} = call;
let returnValue;
switch (func) {
- case 'get': returnValue = cache.get(...args); break;
- case 'set': returnValue = cache.set(...args); break;
- case 'has': returnValue = cache.has(...args); break;
- case 'clear': returnValue = cache.clear(...args); break;
+ case 'get': returnValue = cache.get(args[0]); break;
+ case 'set': returnValue = cache.set(args[0], args[1]); break;
+ case 'has': returnValue = cache.has(args[0]); break;
+ case 'clear': returnValue = cache.clear(); break;
}
if (Object.prototype.hasOwnProperty.call(call, 'returnValue')) {
const {returnValue: expectedReturnValue} = call;
@@ -119,6 +122,7 @@ function testApi() {
}
+/** */
function main() {
testConstructor();
testApi();