mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-25 03:20:23 +01:00
31 lines
863 B
TypeScript
31 lines
863 B
TypeScript
|
import { EXCLUDE_E2E_TESTS_REGEX } from '../common/constants';
|
||
|
import {
|
||
|
filterDiffLineAdditions,
|
||
|
filterDiffByFilePath,
|
||
|
hasNumberOfCodeBlocksIncreased,
|
||
|
} from '../common/shared';
|
||
|
|
||
|
const codeBlocks = [
|
||
|
"import { strict as assert } from 'assert';",
|
||
|
'assert.deepEqual',
|
||
|
'assert.equal',
|
||
|
'assert.rejects',
|
||
|
'assert.strictEqual',
|
||
|
'sinon.',
|
||
|
];
|
||
|
|
||
|
function preventSinonAssertSyntax(diff: string): boolean {
|
||
|
const diffByFilePath = filterDiffByFilePath(diff, EXCLUDE_E2E_TESTS_REGEX);
|
||
|
const diffAdditions = filterDiffLineAdditions(diffByFilePath);
|
||
|
const hashmap = hasNumberOfCodeBlocksIncreased(diffAdditions, codeBlocks);
|
||
|
|
||
|
const haveOccurencesOfAtLeastOneCodeBlockIncreased =
|
||
|
Object.values(hashmap).includes(true);
|
||
|
if (haveOccurencesOfAtLeastOneCodeBlockIncreased) {
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
export { preventSinonAssertSyntax };
|