Skip to content

Commit

Permalink
test: change tests style
Browse files Browse the repository at this point in the history
  • Loading branch information
dristpunk committed Feb 14, 2024
1 parent 3c31976 commit b7a7402
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions test/validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,24 +312,29 @@ describe('Validator', () => {
});
});

describe('proccess contract-level natspec', () => {
it('should ignore missing natspec for a contract if disabled (by default)', () => {
describe('with disabled contract-level natspec', () => {
beforeAll(async () => {
validator = new Validator(mockConfig({ contractNatspec: false }));
node = contract;
});
it('should ignore missing natspec for a contract if disabled (by default)', () => {
const result = validator.validate(node, mockNatspec({}));
expect(result).toEqual([]);
});
});

it('should reveal missing natspec for a contract if enabled', () => {
const newValidator = new Validator(mockConfig({ contractNatspec: true }));
describe('with enforeced contract-level natspec', () => {
beforeAll(() => {
validator = new Validator(mockConfig({ contractNatspec: true }));
node = contract;
const result = newValidator.validate(node, mockNatspec({}));
});
it('should reveal missing natspec for a contract if enabled', () => {
const result = validator.validate(node, mockNatspec({}));
expect(result).toContainEqual(`Contract @notice is missing`);
});

it('should pay attention only to the @notice tag', () => {
const newValidator = new Validator(mockConfig({ contractNatspec: true }));
node = contract;
const result = newValidator.validate(node, mockNatspec({ tags: [{ name: 'author', content: 'Some author' }] }));
const result = validator.validate(node, mockNatspec({ tags: [{ name: 'author', content: 'Some author' }] }));
expect(result).toContainEqual(`Contract @notice is missing`);
expect(result.length).toBe(1);
});
Expand Down

0 comments on commit b7a7402

Please sign in to comment.