Skip to content

Commit

Permalink
chore: updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saadjutt01 committed Apr 5, 2021
1 parent 86554a0 commit 2f07bfa
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lint/lintFile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('lintFile', () => {
path.join(__dirname, '..', 'Example File.sas')
)

expect(results.length).toEqual(9)
expect(results.length).toEqual(8)
expect(results).toContainEqual({
message: 'Line contains trailing spaces',
lineNumber: 1,
Expand Down
2 changes: 1 addition & 1 deletion src/lint/lintFolder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('lintFolder', () => {
const diagnostics = results.get(
path.join(__dirname, '..', 'Example File.sas')
)!
expect(diagnostics.length).toEqual(9)
expect(diagnostics.length).toEqual(8)
expect(diagnostics).toContainEqual({
message: 'Line contains trailing spaces',
lineNumber: 1,
Expand Down
2 changes: 1 addition & 1 deletion src/lint/lintProject.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('lintProject', () => {
const diagnostics = results.get(
path.join(__dirname, '..', 'Example File.sas')
)!
expect(diagnostics.length).toEqual(9)
expect(diagnostics.length).toEqual(8)
expect(diagnostics).toContainEqual({
message: 'Line contains trailing spaces',
lineNumber: 1,
Expand Down
44 changes: 41 additions & 3 deletions src/types/LintConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ describe('LintConfig', () => {
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', () => {
const config = new LintConfig({ indentationMultiple: 5 })

Expand All @@ -58,18 +76,38 @@ describe('LintConfig', () => {
const config = new LintConfig({
noTrailingSpaces: true,
noEncodedPasswords: true,
hasDoxygenHeader: true
hasDoxygenHeader: true,
noSpacesInFileNames: true,
lowerCaseFileNames: true,
maxLineLength: 80,
noTabIndentation: true,
indentationMultiple: 2,
hasMacroNameInMend: true
})

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].type).toEqual(LintRuleType.Line)
expect(config.lineLintRules[1].name).toEqual('noEncodedPasswords')
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].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)
})
})
2 changes: 1 addition & 1 deletion src/types/LintConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class LintConfig {
this.pathLintRules.push(lowerCaseFileNames)
}

if (json?.hasMacroNameInMend !== undefined) {
if (json?.hasMacroNameInMend) {
this.fileLintRules.push(hasMacroNameInMend)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getLintConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('getLintConfig', () => {
const config = await getLintConfig()

expect(config).toBeInstanceOf(LintConfig)
expect(config.fileLintRules.length).toEqual(2)
expect(config.fileLintRules.length).toEqual(1)
expect(config.lineLintRules.length).toEqual(5)
expect(config.pathLintRules.length).toEqual(2)
})
Expand Down

0 comments on commit 2f07bfa

Please sign in to comment.