Skip to content

Commit

Permalink
FIX test
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Apr 8, 2023
1 parent e744f35 commit 0c8e4b0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions test/unit/last.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import assert from 'assert';
import { waitUntil } from 'async-test-util';
import {
dbCount,
BROADCAST_CHANNEL_BY_TOKEN
BROADCAST_CHANNEL_BY_TOKEN,
getFromMapOrThrow
} from '../../';
import config from './config';

Expand Down Expand Up @@ -36,15 +37,21 @@ describe('last.test.ts (' + config.storage.name + ')', () => {
}
});
it('ensure all RemoteMessageChannels have been closed', async () => {
function getStillOpen() {
return Array.from(OPEN_REMOTE_MESSAGE_CHANNELS)
.map(messageChannel => getFromMapOrThrow(CACHE_ITEM_BY_MESSAGE_CHANNEL, messageChannel))
.filter(cacheItem => !cacheItem.keepAlive);
}
try {
await waitUntil(() => {
return OPEN_REMOTE_MESSAGE_CHANNELS.size === 0;
const stillOpen = getStillOpen();
return stillOpen.length === 0;
}, 5 * 1000);
} catch (err) {
const stillOpen = Array.from(OPEN_REMOTE_MESSAGE_CHANNELS);
stillOpen.forEach(messageChannel => {
const stillOpen = getStillOpen();
stillOpen.forEach(cacheItem => {
console.log('open graphql webRemoteMessageChannelssockets:');
console.dir(CACHE_ITEM_BY_MESSAGE_CHANNEL.get(messageChannel));
console.dir(cacheItem);
});
console.log(stillOpen);
throw new Error('not all RemoteMessageChannels have been closed (' + stillOpen.length + ')');
Expand Down

0 comments on commit 0c8e4b0

Please sign in to comment.