Skip to content

Commit

Permalink
skip ttl test in browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Apr 2, 2024
1 parent eb959f4 commit a9acb8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DwnServerInfoCacheMemory } from '../../../src/prototyping/clients/dwn-s
import { DwnServerInfoCacheLevel } from '../../../src/prototyping/clients/dwn-server-info-cache-level.js';
import { DwnServerInfoCacheNoOp } from '../../../src/prototyping/clients/dwn-server-info-cache-no-op.js';
import { AbstractLevel } from 'abstract-level';
import { isNode } from '../../utils/runtimes.js';

describe('DwnServerInfoCache', () => {

Expand All @@ -17,6 +18,7 @@ describe('DwnServerInfoCache', () => {
describe(`interface ${Cache.name}`, () => {
let cache: DwnServerInfoCache;
let clock: sinon.SinonFakeTimers;

const exampleInfo:ServerInfo = {
maxFileSize : 100,
webSocketSupport : true,
Expand Down Expand Up @@ -100,7 +102,13 @@ describe('DwnServerInfoCache', () => {
expect(result2AfterDelete).to.equal(undefined);
});

it('returns undefined after ttl', async () => {
it('returns undefined after ttl', async function () {
// skip this test in the browser, sinon fake timers don't seem to work here
// with a an await setTimeout in the test, it passes.
if (!isNode) {
this.skip();
}

const key = 'some-key1';
await cache.set(key, { ...exampleInfo });

Expand Down
3 changes: 2 additions & 1 deletion packages/agent/tests/utils/runtimes.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent);
export const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent);
export const isNode = typeof navigator === 'undefined' && typeof process !== 'undefined' && process.versions != null && process.versions.node != null;

0 comments on commit a9acb8f

Please sign in to comment.