This repository has been archived by the owner on Oct 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 170
/
Copy pathtest_line_endings.coffee
63 lines (52 loc) · 1.88 KB
/
test_line_endings.coffee
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
path = require 'path'
vows = require 'vows'
assert = require 'assert'
coffeelint = require path.join('..', 'lib', 'coffeelint')
RULE = 'line_endings'
vows.describe(RULE).addBatch({
'Unix line endings':
topic:
'''
x = 1\ny=2
'''
'are allowed by default': (source) ->
errors = coffeelint.lint(source)
assert.isEmpty(errors)
'can be forbidden': (source) ->
config = line_endings: { level: 'error', value: 'windows' }
errors = coffeelint.lint(source, config)
assert.isArray(errors)
assert.lengthOf(errors, 1)
error = errors[0]
assert.equal(error.lineNumber, 1)
assert.equal(error.message, 'Line contains incorrect line endings')
assert.equal(error.context, 'Expected windows')
assert.equal(error.rule, RULE)
'Windows line endings':
topic:
'''
x = 1\r\ny=2
'''
'are allowed by default': (source) ->
errors = coffeelint.lint(source)
assert.isEmpty(errors)
'can be forbidden': (source) ->
config = line_endings: { level: 'error', value: 'unix' }
errors = coffeelint.lint(source, config)
assert.isArray(errors)
assert.lengthOf(errors, 1)
error = errors[0]
assert.equal(error.lineNumber, 1)
assert.equal(error.message, 'Line contains incorrect line endings')
assert.equal(error.context, 'Expected unix')
assert.equal(error.rule, RULE)
'Unknown line endings':
topic:
'''
x = 1\ny=2
'''
'throw errors': (source) ->
config = line_endings: { level: 'error', value: 'osx' }
assert.throws () ->
coffeelint.lint(source, config)
}).export(module)