-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
35 lines (31 loc) · 947 Bytes
/
test.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
var remark = require('remark')
var lint = require('remark-lint')
var lintCode = require('remark-lint-code')
var tap = require('tap')
var eslint = require('./index')
var processor = remark()
.use(lint)
.use(lintCode, {
js: {
module: eslint,
options: {
rules: {
'no-console': 2
}
}
}
})
tap.test('should pass when matching', function (t) {
processor.process('```js\nnope\n```', function (err, file, res) {
t.equal(file.messages.length, 0, 'should have passed')
t.end()
})
})
tap.test('should fail when not matching', function (t) {
processor.process('```js\nvar msg = "wat";\n console.log(msg)\n```', function (err, file, res) {
t.equal(file.messages[0].line, 3, 'should point to line 3')
t.equal(file.messages[0].column, 2, 'should point to column 2')
t.equal(file.messages[0].reason, 'Unexpected console statement.', 'should have failed')
t.end()
})
})