-
Notifications
You must be signed in to change notification settings - Fork 179
/
Copy pathone-contract-per-file.js
68 lines (50 loc) · 2.08 KB
/
one-contract-per-file.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const { assertNoWarnings, assertErrorMessage, assertErrorCount } = require('../../common/asserts')
const linter = require('../../../lib/index')
const contracts = require('../../fixtures/best-practices/one-contract-per-file')
describe('Linter - one-contract-per-file', () => {
it('should not raise error for ONE contract only', () => {
const code = contracts.ONE_CONTRACT
const report = linter.processStr(code, {
rules: { 'one-contract-per-file': 'error' },
})
assertNoWarnings(report)
})
it('should not raise error for ONE contract and multiple interfaces in the same file', () => {
const code = contracts.ONE_CONTRACT_WITH_INTERFACES
const report = linter.processStr(code, {
rules: { 'one-contract-per-file': 'error' },
})
assertNoWarnings(report)
})
it('should not raise error for ONE library and multiple interfaces in the same file', () => {
const code = contracts.ONE_LIBRARY_WITH_INTERFACES
const report = linter.processStr(code, {
rules: { 'one-contract-per-file': 'error' },
})
assertNoWarnings(report)
})
it('should raise error for TWO contracts in same file', () => {
const code = contracts.TWO_CONTRACTS
const report = linter.processStr(code, {
rules: { 'one-contract-per-file': 'error' },
})
assertErrorCount(report, 1)
assertErrorMessage(report, 'Found more than One contract per file. 2 contracts found!')
})
it('should raise error for THREE contracts in same file', () => {
const code = contracts.THREE_CONTRACTS
const report = linter.processStr(code, {
rules: { 'one-contract-per-file': 'error' },
})
assertErrorCount(report, 1)
assertErrorMessage(report, 'Found more than One contract per file. 3 contracts found!')
})
it('should raise error for TWO libraries in same file', () => {
const code = contracts.TWO_LIBRARIES
const report = linter.processStr(code, {
rules: { 'one-contract-per-file': 'error' },
})
assertErrorCount(report, 1)
assertErrorMessage(report, 'Found more than One contract per file. 2 contracts found!')
})
})