Skip to content

Commit

Permalink
tests: move expect.hasAssertions calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ChlodAlejandro committed Oct 28, 2023
1 parent 8cad8b7 commit d875691
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions tests/MediaWikiStandardizedStreamTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ test.each( [
<const>'eventgate-main.test.event',
<const>'test'
] )( '%s', async ( topic ) => {
expect.hasAssertions();
let successCount = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
Expand Down Expand Up @@ -87,6 +86,7 @@ test.each( [
}
} );
await stream.waitUntilClosed();
expect.hasAssertions();
} );

test.each( [
Expand All @@ -95,7 +95,6 @@ test.each( [
<const>'mediawiki.revision-create',
<const>'revision-create'
] )( '%s', async ( topic ) => {
expect.hasAssertions();
let successCount = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
Expand All @@ -112,13 +111,13 @@ test.each( [
}
} );
await stream.waitUntilClosed();
expect.hasAssertions();
} );

test.each( [
<const>'mediawiki.page-delete',
<const>'page-delete'
] )( '%s', async ( topic ) => {
expect.hasAssertions();
let successCount = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
Expand All @@ -136,13 +135,13 @@ test.each( [
}
} );
await stream.waitUntilClosed();
expect.hasAssertions();
} );

test.each( [
<const>'mediawiki.page-links-change',
<const>'page-links-change'
] )( '%s', async ( topic ) => {
expect.hasAssertions();
let successCount = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
Expand Down Expand Up @@ -172,13 +171,13 @@ test.each( [
}
} );
await stream.waitUntilClosed();
expect.hasAssertions();
} );

test.each( [
<const>'mediawiki.page-move',
<const>'page-move'
] )( '%s', async ( topic ) => {
expect.hasAssertions();
let successCount = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
Expand All @@ -205,13 +204,13 @@ test.each( [
}
} );
await stream.waitUntilClosed();
expect.hasAssertions();
} );

test.each( [
<const>'mediawiki.page-properties-change',
<const>'page-properties-change'
] )( '%s', async ( topic ) => {
expect.hasAssertions();
let successCount = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
Expand All @@ -237,13 +236,13 @@ test.each( [
}
} );
await stream.waitUntilClosed();
expect.hasAssertions();
} );

test.each( [
<const>'mediawiki.page-undelete',
<const>'page-undelete'
] )( '%s', async ( topic ) => {
expect.hasAssertions();
let successCount = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
Expand All @@ -263,12 +262,12 @@ test.each( [
}
} );
await stream.waitUntilClosed();
expect.hasAssertions();
} );

test.each( [
<const>'mediawiki.revision-tags-change'
] )( '%s', async ( topic ) => {
expect.hasAssertions();
let successCount = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
Expand All @@ -290,12 +289,12 @@ test.each( [
}
} );
await stream.waitUntilClosed();
expect.hasAssertions();
} );

test.each( [
<const>'mediawiki.revision-visibility-change'
] )( '%s', async ( topic ) => {
expect.hasAssertions();
let successCount = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
Expand All @@ -320,4 +319,5 @@ test.each( [
}
} );
await stream.waitUntilClosed();
expect.hasAssertions();
} );
12 changes: 6 additions & 6 deletions tests/WikimediaStreamFilterTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe( 'WikimediaStreamFilter tests', () => {
} );

test( 'none', ( doneFn ) => {
expect.hasAssertions();
const filter = stream.filter( 'recentchange' )
.none( {
wiki: 'enwiki'
Expand All @@ -33,15 +32,15 @@ describe( 'WikimediaStreamFilter tests', () => {
expect( data.$schema ).toBe( '/mediawiki/recentchange/1.0.0' );
expect( data.wiki ).not.toBe( 'enwiki' );
} );

setTimeout( () => {
filter.removeAllListeners();
expect.hasAssertions();
doneFn();
}, 5e3 );

}, 20e3 );

test( 'all', ( doneFn ) => {
expect.hasAssertions();
const filter = stream.filter( 'recentchange' )
.all( {
wiki: 'wikidatawiki'
Expand All @@ -53,12 +52,12 @@ describe( 'WikimediaStreamFilter tests', () => {

setTimeout( () => {
filter.removeAllListeners();
expect.hasAssertions();
doneFn();
}, 5e3 );
}, 20e3 );

test( 'any', ( doneFn ) => {
expect.hasAssertions();
const filter = stream.filter( 'recentchange' )
.any( {
wiki: 'commonswiki'
Expand All @@ -74,12 +73,12 @@ describe( 'WikimediaStreamFilter tests', () => {

setTimeout( () => {
filter.removeAllListeners();
expect.hasAssertions();
doneFn();
}, 5e3 );
}, 20e3 );

test( 'depth 2', ( doneFn ) => {
expect.hasAssertions();
const filter = stream.filter( 'recentchange' )
.all( {
meta: {
Expand All @@ -93,6 +92,7 @@ describe( 'WikimediaStreamFilter tests', () => {

setTimeout( () => {
filter.removeAllListeners();
expect.hasAssertions();
doneFn();
}, 5e3 );
}, 20e3 );
Expand Down Expand Up @@ -120,7 +120,6 @@ describe( 'WikimediaStreamFilter tests', () => {
}, 20e3 );

test( 'cloning', ( doneFn ) => {
expect.hasAssertions();
const fakeFunction1 = jest.fn();
const fakeFunction2 = jest.fn();
const fakeFunction3 = jest.fn();
Expand Down Expand Up @@ -174,6 +173,7 @@ describe( 'WikimediaStreamFilter tests', () => {
expect( fakeFunction3 ).toBeCalled();
filter1.removeAllListeners();
filter2.removeAllListeners();
expect.hasAssertions();
doneFn();
}, 5e3 );
}, 20e3 );
Expand Down
6 changes: 3 additions & 3 deletions tests/WikimediaStreamTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ describe( 'WikimediaStream tests', () => {
} );

test( 'cfg lastEventId: test with offset', async () => {
expect.hasAssertions();
let referenceEvent : MediaWikiRecentChangeEvent;

const stream1 = new WikimediaStream( 'recentchange' );
Expand Down Expand Up @@ -88,10 +87,10 @@ describe( 'WikimediaStream tests', () => {
} );
await stream2.open();
await stream2.waitUntilClosed();
expect.hasAssertions();
} );

test( 'cfg since: similar time', async () => {
expect.hasAssertions();
let referenceEvent : MediaWikiRecentChangeEvent;

const stream1 = new WikimediaStream( 'recentchange' );
Expand All @@ -117,6 +116,7 @@ describe( 'WikimediaStream tests', () => {
} );
await stream2.open();
await stream2.waitUntilClosed();
expect.hasAssertions();
} );

test( 'get lastEventId: lastEventId is automatically saved', async () => {
Expand Down Expand Up @@ -244,7 +244,6 @@ describe( 'WikimediaStream tests', () => {
} );

test( 'fn waitUntilClosed(): waits until closed', async () => {
expect.hasAssertions();
const stream = new WikimediaStream( 'recentchange' );
stream.on( 'open', () => {
stream.close();
Expand All @@ -256,6 +255,7 @@ describe( 'WikimediaStream tests', () => {
} )
] );
expect( stream.eventSource ).toBeNull();
expect.hasAssertions();
} );

test( 'fn waitUntilClosed(): returns immediately if already closed', async () => {
Expand Down

0 comments on commit d875691

Please sign in to comment.