mirror of
https://github.com/sasjs/lint.git
synced 2026-01-09 21:40:06 +00:00
chore: updated tests
This commit is contained in:
@@ -8,7 +8,7 @@ describe('lintFile', () => {
|
|||||||
path.join(__dirname, '..', 'Example File.sas')
|
path.join(__dirname, '..', 'Example File.sas')
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(results.length).toEqual(9)
|
expect(results.length).toEqual(8)
|
||||||
expect(results).toContainEqual({
|
expect(results).toContainEqual({
|
||||||
message: 'Line contains trailing spaces',
|
message: 'Line contains trailing spaces',
|
||||||
lineNumber: 1,
|
lineNumber: 1,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ describe('lintFolder', () => {
|
|||||||
const diagnostics = results.get(
|
const diagnostics = results.get(
|
||||||
path.join(__dirname, '..', 'Example File.sas')
|
path.join(__dirname, '..', 'Example File.sas')
|
||||||
)!
|
)!
|
||||||
expect(diagnostics.length).toEqual(9)
|
expect(diagnostics.length).toEqual(8)
|
||||||
expect(diagnostics).toContainEqual({
|
expect(diagnostics).toContainEqual({
|
||||||
message: 'Line contains trailing spaces',
|
message: 'Line contains trailing spaces',
|
||||||
lineNumber: 1,
|
lineNumber: 1,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ describe('lintProject', () => {
|
|||||||
const diagnostics = results.get(
|
const diagnostics = results.get(
|
||||||
path.join(__dirname, '..', 'Example File.sas')
|
path.join(__dirname, '..', 'Example File.sas')
|
||||||
)!
|
)!
|
||||||
expect(diagnostics.length).toEqual(9)
|
expect(diagnostics.length).toEqual(8)
|
||||||
expect(diagnostics).toContainEqual({
|
expect(diagnostics).toContainEqual({
|
||||||
message: 'Line contains trailing spaces',
|
message: 'Line contains trailing spaces',
|
||||||
lineNumber: 1,
|
lineNumber: 1,
|
||||||
|
|||||||
@@ -40,6 +40,24 @@ describe('LintConfig', () => {
|
|||||||
expect(config.fileLintRules[0].type).toEqual(LintRuleType.File)
|
expect(config.fileLintRules[0].type).toEqual(LintRuleType.File)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should create an instance with the hasMacroNameInMend flag set', () => {
|
||||||
|
const config = new LintConfig({ hasMacroNameInMend: true })
|
||||||
|
|
||||||
|
expect(config).toBeTruthy()
|
||||||
|
expect(config.lineLintRules.length).toEqual(0)
|
||||||
|
expect(config.fileLintRules.length).toEqual(1)
|
||||||
|
expect(config.fileLintRules[0].name).toEqual('hasMacroNameInMend')
|
||||||
|
expect(config.fileLintRules[0].type).toEqual(LintRuleType.File)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should create an instance with the hasMacroNameInMend flag off', () => {
|
||||||
|
const config = new LintConfig({ hasMacroNameInMend: false })
|
||||||
|
|
||||||
|
expect(config).toBeTruthy()
|
||||||
|
expect(config.lineLintRules.length).toEqual(0)
|
||||||
|
expect(config.fileLintRules.length).toEqual(0)
|
||||||
|
})
|
||||||
|
|
||||||
it('should create an instance with the indentation multiple set', () => {
|
it('should create an instance with the indentation multiple set', () => {
|
||||||
const config = new LintConfig({ indentationMultiple: 5 })
|
const config = new LintConfig({ indentationMultiple: 5 })
|
||||||
|
|
||||||
@@ -58,18 +76,38 @@ describe('LintConfig', () => {
|
|||||||
const config = new LintConfig({
|
const config = new LintConfig({
|
||||||
noTrailingSpaces: true,
|
noTrailingSpaces: true,
|
||||||
noEncodedPasswords: true,
|
noEncodedPasswords: true,
|
||||||
hasDoxygenHeader: true
|
hasDoxygenHeader: true,
|
||||||
|
noSpacesInFileNames: true,
|
||||||
|
lowerCaseFileNames: true,
|
||||||
|
maxLineLength: 80,
|
||||||
|
noTabIndentation: true,
|
||||||
|
indentationMultiple: 2,
|
||||||
|
hasMacroNameInMend: true
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(config).toBeTruthy()
|
expect(config).toBeTruthy()
|
||||||
expect(config.lineLintRules.length).toEqual(2)
|
expect(config.lineLintRules.length).toEqual(5)
|
||||||
expect(config.lineLintRules[0].name).toEqual('noTrailingSpaces')
|
expect(config.lineLintRules[0].name).toEqual('noTrailingSpaces')
|
||||||
expect(config.lineLintRules[0].type).toEqual(LintRuleType.Line)
|
expect(config.lineLintRules[0].type).toEqual(LintRuleType.Line)
|
||||||
expect(config.lineLintRules[1].name).toEqual('noEncodedPasswords')
|
expect(config.lineLintRules[1].name).toEqual('noEncodedPasswords')
|
||||||
expect(config.lineLintRules[1].type).toEqual(LintRuleType.Line)
|
expect(config.lineLintRules[1].type).toEqual(LintRuleType.Line)
|
||||||
|
expect(config.lineLintRules[2].name).toEqual('noTabs')
|
||||||
|
expect(config.lineLintRules[2].type).toEqual(LintRuleType.Line)
|
||||||
|
expect(config.lineLintRules[3].name).toEqual('maxLineLength')
|
||||||
|
expect(config.lineLintRules[3].type).toEqual(LintRuleType.Line)
|
||||||
|
expect(config.lineLintRules[4].name).toEqual('indentationMultiple')
|
||||||
|
expect(config.lineLintRules[4].type).toEqual(LintRuleType.Line)
|
||||||
|
|
||||||
expect(config.fileLintRules.length).toEqual(1)
|
expect(config.fileLintRules.length).toEqual(2)
|
||||||
expect(config.fileLintRules[0].name).toEqual('hasDoxygenHeader')
|
expect(config.fileLintRules[0].name).toEqual('hasDoxygenHeader')
|
||||||
expect(config.fileLintRules[0].type).toEqual(LintRuleType.File)
|
expect(config.fileLintRules[0].type).toEqual(LintRuleType.File)
|
||||||
|
expect(config.fileLintRules[1].name).toEqual('hasMacroNameInMend')
|
||||||
|
expect(config.fileLintRules[1].type).toEqual(LintRuleType.File)
|
||||||
|
|
||||||
|
expect(config.pathLintRules.length).toEqual(2)
|
||||||
|
expect(config.pathLintRules[0].name).toEqual('noSpacesInFileNames')
|
||||||
|
expect(config.pathLintRules[0].type).toEqual(LintRuleType.Path)
|
||||||
|
expect(config.pathLintRules[1].name).toEqual('lowerCaseFileNames')
|
||||||
|
expect(config.pathLintRules[1].type).toEqual(LintRuleType.Path)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export class LintConfig {
|
|||||||
this.pathLintRules.push(lowerCaseFileNames)
|
this.pathLintRules.push(lowerCaseFileNames)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json?.hasMacroNameInMend !== undefined) {
|
if (json?.hasMacroNameInMend) {
|
||||||
this.fileLintRules.push(hasMacroNameInMend)
|
this.fileLintRules.push(hasMacroNameInMend)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ describe('getLintConfig', () => {
|
|||||||
const config = await getLintConfig()
|
const config = await getLintConfig()
|
||||||
|
|
||||||
expect(config).toBeInstanceOf(LintConfig)
|
expect(config).toBeInstanceOf(LintConfig)
|
||||||
expect(config.fileLintRules.length).toEqual(2)
|
expect(config.fileLintRules.length).toEqual(1)
|
||||||
expect(config.lineLintRules.length).toEqual(5)
|
expect(config.lineLintRules.length).toEqual(5)
|
||||||
expect(config.pathLintRules.length).toEqual(2)
|
expect(config.pathLintRules.length).toEqual(2)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user