Skip to content

Commit

Permalink
switch to object use
Browse files Browse the repository at this point in the history
  • Loading branch information
ChlodAlejandro committed Oct 30, 2023
1 parent adcab6b commit 01a6207
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions tests/MediaWikiStandardizedStreamTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
isMediaWikiRevisionTagsChangeEvent
} from '../src/streams/MediaWikiRevisionTagsChangeEvent';

const successes: Partial<Record<WikimediaEventStream, number>> = {};

beforeAll( () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
expect( WikimediaStream.VERSION ).toBe( require( '../package.json' ).version );
Expand Down Expand Up @@ -63,7 +65,7 @@ test.each( [
<const>'eventgate-main.test.event',
<const>'test'
] )( '%s', async ( topic ) => {
let successCount = 0;
successes[ topic ] = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
expect( isWikimediaEvent( data ) ).toBe( false );
Expand All @@ -87,7 +89,7 @@ test.each( [
expect( typeof data.test_map ).toEqual( 'object' );
}
console.log( 'probe 11' + topic );
if ( ++successCount > 20 ) {
if ( ++successes[ topic ] > 20 ) {
console.log( 'probe 12' + topic );
stream.close();
}
Expand All @@ -105,7 +107,7 @@ test.each( [
<const>'mediawiki.revision-create',
<const>'revision-create'
] )( '%s', async ( topic ) => {
let successCount = 0;
successes[ topic ] = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
expect( isMediaWikiEvent( data ) || data ).toBe( true );
Expand All @@ -117,7 +119,7 @@ test.each( [
testUser( data.performer );
}
console.log( 'probe 11' + topic );
if ( ++successCount > 20 ) {
if ( ++successes[ topic ] > 20 ) {
console.log( 'probe 12' + topic );
stream.close();
}
Expand All @@ -133,7 +135,7 @@ test.each( [
<const>'mediawiki.page-delete',
<const>'page-delete'
] )( '%s', async ( topic ) => {
let successCount = 0;
successes[ topic ] = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
expect( isMediaWikiPageDeleteEvent( data ) || data ).toBe( true );
Expand All @@ -146,7 +148,7 @@ test.each( [
expect( typeof data.rev_id ).toBe( 'number' );
expect( typeof data.rev_count ).toBe( 'number' );
console.log( 'probe 11' + topic );
if ( ++successCount > 20 ) {
if ( ++successes[ topic ] > 20 ) {
console.log( 'probe 12' + topic );
stream.close();
}
Expand All @@ -162,7 +164,7 @@ test.each( [
<const>'mediawiki.page-links-change',
<const>'page-links-change'
] )( '%s', async ( topic ) => {
let successCount = 0;
successes[ topic ] = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
expect( isMediaWikiPageLinksChangeEvent( data ) || data ).toBe( true );
Expand All @@ -187,7 +189,7 @@ test.each( [
}
}
console.log( 'probe 11' + topic );
if ( ++successCount > 20 ) {
if ( ++successes[ topic ] > 20 ) {
console.log( 'probe 12' + topic );
stream.close();
}
Expand All @@ -203,7 +205,7 @@ test.each( [
<const>'mediawiki.page-move',
<const>'page-move'
] )( '%s', async ( topic ) => {
let successCount = 0;
successes[ topic ] = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
expect( isMediaWikiPageMoveEvent( data ) || data ).toBe( true );
Expand All @@ -225,7 +227,7 @@ test.each( [
expect( typeof data.new_redirect_page.rev_id ).toBe( 'number' );
}
console.log( 'probe 11' + topic );
if ( ++successCount > 20 ) {
if ( ++successes[ topic ] > 20 ) {
console.log( 'probe 12' + topic );
stream.close();
}
Expand All @@ -241,7 +243,7 @@ test.each( [
<const>'mediawiki.page-properties-change',
<const>'page-properties-change'
] )( '%s', async ( topic ) => {
let successCount = 0;
successes[ topic ] = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
expect( isMediaWikiPagePropertiesChangeEvent( data ) || data ).toBe( true );
Expand All @@ -262,7 +264,7 @@ test.each( [
}
expect( propertiesFound ).toBeTruthy();
console.log( 'probe 11' + topic );
if ( ++successCount > 20 ) {
if ( ++successes[ topic ] > 20 ) {
console.log( 'probe 12' + topic );
stream.close();
}
Expand All @@ -278,7 +280,7 @@ test.each( [
<const>'mediawiki.page-undelete',
<const>'page-undelete'
] )( '%s', async ( topic ) => {
let successCount = 0;
successes[ topic ] = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
expect( isMediaWikiPagePropertiesChangeEvent( data ) || data ).toBe( true );
Expand All @@ -293,7 +295,7 @@ test.each( [
expect( typeof data.prior_state.page_id ).toBe( 'number' );
}
console.log( 'probe 11' + topic );
if ( ++successCount > 20 ) {
if ( ++successes[ topic ] > 20 ) {
console.log( 'probe 12' + topic );
stream.close();
}
Expand All @@ -308,7 +310,7 @@ test.each( [
test.each( [
<const>'mediawiki.revision-tags-change'
] )( '%s', async ( topic ) => {
let successCount = 0;
successes[ topic ] = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
expect( isMediaWikiRevisionTagsChangeEvent( data ) || data ).toBe( true );
Expand All @@ -325,7 +327,7 @@ test.each( [
expect( typeof priorTag ).toBe( 'string' );
}
console.log( 'probe 11' + topic );
if ( ++successCount > 20 ) {
if ( ++successes[ topic ] > 20 ) {
console.log( 'probe 12' + topic );
stream.close();
}
Expand All @@ -340,7 +342,7 @@ test.each( [
test.each( [
<const>'mediawiki.revision-visibility-change'
] )( '%s', async ( topic ) => {
let successCount = 0;
successes[ topic ] = 0;
const stream = await generateStream( topic );
stream.on( topic, ( data ) => {
expect( isMediaWikiRevisionVisibilityChangeEvent( data ) || data ).toBe( true );
Expand All @@ -360,7 +362,7 @@ test.each( [
expect( typeof data.prior_state.visibility.user ).toBe( 'boolean' );
expect( typeof data.prior_state.visibility.comment ).toBe( 'boolean' );
console.log( 'probe 11' + topic );
if ( ++successCount > 20 ) {
if ( ++successes[ topic ] > 20 ) {
console.log( 'probe 12' + topic );
stream.close();
}
Expand Down

0 comments on commit 01a6207

Please sign in to comment.