-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor test filters to typescript (#4054)
Co-authored-by: Bailey Pearson <bailey.pearson@mongodb.com>
- Loading branch information
1 parent
db00ac4
commit 17febb4
Showing
16 changed files
with
196 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { type Test } from 'mocha'; | ||
|
||
import { type MongoClient } from '../../../mongodb'; | ||
|
||
export abstract class Filter { | ||
async initializeFilter(_client: MongoClient, _context: Record<string, any>): Promise<void> { | ||
return; | ||
} | ||
|
||
abstract filter(test: Test): string | boolean; | ||
} |
18 changes: 9 additions & 9 deletions
18
...unner/filters/generic_predicate_filter.js → ...unner/filters/generic_predicate_filter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Generic filter than can run predicates. | ||
* | ||
* Predicates cannot be async. The test is skipped if the predicate returns | ||
* a string. The string returned should be a skip reason. | ||
* | ||
* example: | ||
* @example | ||
* ```js | ||
* metadata: { | ||
* requires: { | ||
* predicate: (test: Mocha.Test) => true | string | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
|
||
class GenericPredicateFilter { | ||
filter(test) { | ||
/** @type{ ((test?: Mocha.Test) => string | true) | undefined } */ | ||
const predicate = test?.metadata?.requires?.predicate; | ||
import { type Test } from 'mocha'; | ||
|
||
import { Filter } from './filter'; | ||
|
||
export class GenericPredicateFilter extends Filter { | ||
filter(test: Test & { metadata?: MongoDBMetadataUI }) { | ||
const predicate = test?.metadata?.requires?.predicate; | ||
return predicate?.(test) ?? true; | ||
} | ||
} | ||
|
||
module.exports = GenericPredicateFilter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.