mirror of
https://github.com/sasjs/lint.git
synced 2026-01-12 23:00:05 +00:00
feat(*): add line endings rule, add automatic formatting for fixable violations
This commit is contained in:
41
src/utils/splitText.spec.ts
Normal file
41
src/utils/splitText.spec.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { LintConfig } from '../types'
|
||||
import { splitText } from './splitText'
|
||||
|
||||
describe('splitText', () => {
|
||||
const config = new LintConfig({
|
||||
noTrailingSpaces: true,
|
||||
noEncodedPasswords: true,
|
||||
hasDoxygenHeader: true,
|
||||
noSpacesInFileNames: true,
|
||||
maxLineLength: 80,
|
||||
lowerCaseFileNames: true,
|
||||
noTabIndentation: true,
|
||||
indentationMultiple: 2,
|
||||
hasMacroNameInMend: true,
|
||||
noNestedMacros: true,
|
||||
hasMacroParentheses: true,
|
||||
lineEndings: 'lf'
|
||||
})
|
||||
|
||||
it('should return an empty array when text is falsy', () => {
|
||||
const lines = splitText('', config)
|
||||
|
||||
expect(lines.length).toEqual(0)
|
||||
})
|
||||
|
||||
it('should return an array of lines from text', () => {
|
||||
const lines = splitText(`line 1\nline 2`, config)
|
||||
|
||||
expect(lines.length).toEqual(2)
|
||||
expect(lines[0]).toEqual('line 1')
|
||||
expect(lines[1]).toEqual('line 2')
|
||||
})
|
||||
|
||||
it('should work with CRLF line endings', () => {
|
||||
const lines = splitText(`line 1\r\nline 2`, config)
|
||||
|
||||
expect(lines.length).toEqual(2)
|
||||
expect(lines[0]).toEqual('line 1')
|
||||
expect(lines[1]).toEqual('line 2')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user