Skip to content

Commit

Permalink
test: separate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dristpunk committed Feb 14, 2024
1 parent 35413c1 commit 62f3b9d
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions test/validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,28 @@ describe('Validator', () => {
expect(result).toEqual([]);
});

it('should validate constructor if configured', () => {
// constructorNatspec = false by default
node = contract.vFunctions.find(({ kind }) => kind === 'constructor')!;
const result = validator.validate(node, mockNatspec({}));
expect(result).toEqual([]);
// constructorNatspec = true
validator = new Validator(mockConfig({ constructorNatspec: true }));
const result2 = validator.validate(node, mockNatspec({}));
expectWarning(result2, `@param _randomFlag is missing`, 1);
describe('with enforced constructor natspec', () => {
beforeAll(async () => {
validator = new Validator(mockConfig({ constructorNatspec: true }));
node = contract.vFunctions.find(({ kind }) => kind === 'constructor')!;
});

it('should reveal missing constructor natspec', () => {
const result = validator.validate(node, mockNatspec({}));
expectWarning(result, `@param _randomFlag is missing`, 1);
});
});

describe('with disabled constructor natspec', () => {
beforeAll(async () => {
validator = new Validator(mockConfig({ constructorNatspec: false }));
node = contract.vFunctions.find(({ kind }) => kind === 'constructor')!;
});

it('should ignore missing constructor natspec', () => {
const result = validator.validate(node, mockNatspec({}));
expect(result).toEqual([]);
});
});

describe('with enforced inheritdoc', () => {
Expand Down

0 comments on commit 62f3b9d

Please sign in to comment.