From 2f07bfa0a15bad4abd051ea287ff4786b744d3b3 Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Mon, 5 Apr 2021 22:58:59 +0500 Subject: [PATCH] chore: updated tests --- src/lint/lintFile.spec.ts | 2 +- src/lint/lintFolder.spec.ts | 2 +- src/lint/lintProject.spec.ts | 2 +- src/types/LintConfig.spec.ts | 44 ++++++++++++++++++++++++++++++--- src/types/LintConfig.ts | 2 +- src/utils/getLintConfig.spec.ts | 2 +- 6 files changed, 46 insertions(+), 8 deletions(-) diff --git a/src/lint/lintFile.spec.ts b/src/lint/lintFile.spec.ts index 1843393..a7de9ef 100644 --- a/src/lint/lintFile.spec.ts +++ b/src/lint/lintFile.spec.ts @@ -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, diff --git a/src/lint/lintFolder.spec.ts b/src/lint/lintFolder.spec.ts index 49ed8fa..7124d3e 100644 --- a/src/lint/lintFolder.spec.ts +++ b/src/lint/lintFolder.spec.ts @@ -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, diff --git a/src/lint/lintProject.spec.ts b/src/lint/lintProject.spec.ts index 4bc4963..3a0b200 100644 --- a/src/lint/lintProject.spec.ts +++ b/src/lint/lintProject.spec.ts @@ -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, diff --git a/src/types/LintConfig.spec.ts b/src/types/LintConfig.spec.ts index e11cd83..bc88fc3 100644 --- a/src/types/LintConfig.spec.ts +++ b/src/types/LintConfig.spec.ts @@ -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 }) @@ -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) }) }) diff --git a/src/types/LintConfig.ts b/src/types/LintConfig.ts index 60b49df..f8e57c2 100644 --- a/src/types/LintConfig.ts +++ b/src/types/LintConfig.ts @@ -58,7 +58,7 @@ export class LintConfig { this.pathLintRules.push(lowerCaseFileNames) } - if (json?.hasMacroNameInMend !== undefined) { + if (json?.hasMacroNameInMend) { this.fileLintRules.push(hasMacroNameInMend) } } diff --git a/src/utils/getLintConfig.spec.ts b/src/utils/getLintConfig.spec.ts index 65d64bd..e7e4870 100644 --- a/src/utils/getLintConfig.spec.ts +++ b/src/utils/getLintConfig.spec.ts @@ -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) })