1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-28 05:12:18 +01:00
metamask-extension/development/fitness-functions/rules/sinon-assert-syntax.test.ts
Pedro Figueiredo 632ae0b7c3
Prevent new JS files in shared folder (#17737)
* Prevent new JS files in shared folder

* migrate to typescript

* fix types

* cleanup
2023-04-24 15:44:42 +01:00

30 lines
935 B
TypeScript

import { generateModifyFilesDiff } from '../common/test-data';
import { preventSinonAssertSyntax } from './sinon-assert-syntax';
describe('preventSinonAssertSyntax()', (): void => {
it('should pass when receiving an empty diff', (): void => {
const testDiff = '';
const hasRulePassed = preventSinonAssertSyntax(testDiff);
expect(hasRulePassed).toBe(true);
});
it('should not pass when receiving a diff with one of the blocked expressions', (): void => {
const infringingExpression = 'assert.equal';
const testDiff = [
generateModifyFilesDiff('new-file.ts', 'foo', 'bar'),
generateModifyFilesDiff('old-file.js', undefined, 'pong'),
generateModifyFilesDiff(
'test.js',
`yada yada ${infringingExpression} yada yada`,
undefined,
),
].join('');
const hasRulePassed = preventSinonAssertSyntax(testDiff);
expect(hasRulePassed).toBe(false);
});
});