1 | const assert = require('assert')
|
2 | const linter = require('./../../../lib/index')
|
3 |
|
4 | describe('Linter - imports-on-top', () => {
|
5 | it('should raise import not on top error', () => {
|
6 | const code = `
|
7 | contract A {}
|
8 |
|
9 |
|
10 | import "lib.sol";
|
11 | `
|
12 |
|
13 | const report = linter.processStr(code, {
|
14 | rules: { 'imports-on-top': 'error' }
|
15 | })
|
16 |
|
17 | assert.equal(report.errorCount, 1)
|
18 | assert.ok(report.messages[0].message.includes('Import'))
|
19 | })
|
20 |
|
21 | it('should not raise import not on top error', () => {
|
22 | const code = `
|
23 | pragma solidity 0.4.17;
|
24 | import "lib.sol";
|
25 |
|
26 |
|
27 | contract A {}
|
28 | `
|
29 |
|
30 | const report = linter.processStr(code, {
|
31 | rules: { 'imports-on-top': 'error' }
|
32 | })
|
33 |
|
34 | assert.equal(report.errorCount, 0)
|
35 | })
|
36 | })
|