-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
37 lines (31 loc) · 905 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
36
37
const assert = require('assert');
const { ESLint } = require("eslint");
const cli = new ESLint({
overrideConfigFile: 'index.js',
});
const lint = text => cli.lintText(text);
describe('Non-react JS', function () {
it('Will pass', async function () {
const test = await lint(`const foo = 'foo'; window.location(foo);\n`);
const message = test[0].errorCount > 0 && test[0].messages[0].message;
assert.equal(test[0].errorCount, 0, message);
});
});
describe('React JS', function () {
it('Will pass', async function () {
const test = await lint(
`import React, { Component } from 'react';
export class Foo extends Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
return <p>Foo</p>;
}
}
` );
const message = test[0].errorCount > 0 && test[0].messages[0].message;
assert.equal(test[0].errorCount, 0, message);
});
});