This repository has been archived by the owner on Feb 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.js
62 lines (49 loc) · 1.54 KB
/
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
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
const expect = require('chai').expect;
const Plugin = require('.');
describe('Plugin', function() {
var plugin;
beforeEach(function() {
plugin = new Plugin({
plugins: {
coffeelint: {
options: {no_trailing_semicolons: { level: "ignore"} }
}
}
});
});
it('should be an object', function() {
expect(plugin).to.be.ok;
});
it('should has #lint method', function() {
expect(plugin.lint).to.be.an.instanceof(Function);
});
it('should lint correctly', function(done) {
var content = 'a = 228\nb = () ->\n console.log a'
plugin.lint(content, 'file.coffee').then(() => done(), error => expect(error).not.to.be.ok);
});
it('should give correct errors', function(done) {
var content = 'b = () ->\n\t\t a=10'
plugin.lint(content, 'file.coffee').then(null, error => {
expect(error).to.contain('error: indentation at line 2. Expected 2 got 5\nerror: no_tabs at line 2.');
done();
});
});
it('should read configs global options list', function(done) {
var content = 'alert("end of line");'
plugin.lint(content, 'file.coffee').then(() => done(), error => expect(error).not.to.be.ok);
});
it('should read coffeelint.json', function(done) {
var content = 'a++'
plugin = new Plugin({
plugins: {
coffeelint: {
useCoffeelintJson: true
}
}
});
plugin.lint(content, 'file.coffee').then(null, error => {
expect(error).to.contain('error: no_plusplus at line 1. found \'++\'');
done();
});
});
});