mirror of
https://github.com/sasjs/lint.git
synced 2026-01-07 12:40:05 +00:00
chore(tests): changed numeric literals -> consts
This commit is contained in:
@@ -2,13 +2,15 @@ import { lintFile } from './lintFile'
|
|||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../types/Severity'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
|
const expectedDiagnosticsCount = 9
|
||||||
|
|
||||||
describe('lintFile', () => {
|
describe('lintFile', () => {
|
||||||
it('should identify lint issues in a given file', async () => {
|
it('should identify lint issues in a given file', async () => {
|
||||||
const results = await lintFile(
|
const results = await lintFile(
|
||||||
path.join(__dirname, '..', 'Example File.sas')
|
path.join(__dirname, '..', 'Example File.sas')
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(results.length).toEqual(9)
|
expect(results.length).toEqual(expectedDiagnosticsCount)
|
||||||
expect(results).toContainEqual({
|
expect(results).toContainEqual({
|
||||||
message: 'Line contains trailing spaces',
|
message: 'Line contains trailing spaces',
|
||||||
lineNumber: 1,
|
lineNumber: 1,
|
||||||
|
|||||||
@@ -2,15 +2,18 @@ import { lintFolder } from './lintFolder'
|
|||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../types/Severity'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
|
const expectedFilesCount = 1
|
||||||
|
const expectedDiagnosticsCount = 9
|
||||||
|
|
||||||
describe('lintFolder', () => {
|
describe('lintFolder', () => {
|
||||||
it('should identify lint issues in a given folder', async () => {
|
it('should identify lint issues in a given folder', async () => {
|
||||||
const results = await lintFolder(path.join(__dirname, '..'))
|
const results = await lintFolder(path.join(__dirname, '..'))
|
||||||
|
|
||||||
expect(results.size).toEqual(1)
|
expect(results.size).toEqual(expectedFilesCount)
|
||||||
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(expectedDiagnosticsCount)
|
||||||
expect(diagnostics).toContainEqual({
|
expect(diagnostics).toContainEqual({
|
||||||
message: 'Line contains trailing spaces',
|
message: 'Line contains trailing spaces',
|
||||||
lineNumber: 1,
|
lineNumber: 1,
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import * as utils from '../utils'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
jest.mock('../utils')
|
jest.mock('../utils')
|
||||||
|
|
||||||
|
const expectedFilesCount = 1
|
||||||
|
const expectedDiagnosticsCount = 9
|
||||||
|
|
||||||
describe('lintProject', () => {
|
describe('lintProject', () => {
|
||||||
it('should identify lint issues in a given project', async () => {
|
it('should identify lint issues in a given project', async () => {
|
||||||
jest
|
jest
|
||||||
@@ -11,11 +14,11 @@ describe('lintProject', () => {
|
|||||||
.mockImplementationOnce(() => Promise.resolve(path.join(__dirname, '..')))
|
.mockImplementationOnce(() => Promise.resolve(path.join(__dirname, '..')))
|
||||||
const results = await lintProject()
|
const results = await lintProject()
|
||||||
|
|
||||||
expect(results.size).toEqual(1)
|
expect(results.size).toEqual(expectedFilesCount)
|
||||||
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(expectedDiagnosticsCount)
|
||||||
expect(diagnostics).toContainEqual({
|
expect(diagnostics).toContainEqual({
|
||||||
message: 'Line contains trailing spaces',
|
message: 'Line contains trailing spaces',
|
||||||
lineNumber: 1,
|
lineNumber: 1,
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ import * as fileModule from '@sasjs/utils/file'
|
|||||||
import { LintConfig } from '../types/LintConfig'
|
import { LintConfig } from '../types/LintConfig'
|
||||||
import { getLintConfig } from './getLintConfig'
|
import { getLintConfig } from './getLintConfig'
|
||||||
|
|
||||||
|
const expectedFileLintRulesCount = 4
|
||||||
|
const expectedLineLintRulesCount = 5
|
||||||
|
const expectedPathLintRulesCount = 2
|
||||||
|
|
||||||
describe('getLintConfig', () => {
|
describe('getLintConfig', () => {
|
||||||
it('should get the lint config', async () => {
|
it('should get the lint config', async () => {
|
||||||
const config = await getLintConfig()
|
const config = await getLintConfig()
|
||||||
@@ -17,8 +21,8 @@ describe('getLintConfig', () => {
|
|||||||
const config = await getLintConfig()
|
const config = await getLintConfig()
|
||||||
|
|
||||||
expect(config).toBeInstanceOf(LintConfig)
|
expect(config).toBeInstanceOf(LintConfig)
|
||||||
expect(config.fileLintRules.length).toEqual(4)
|
expect(config.fileLintRules.length).toEqual(expectedFileLintRulesCount)
|
||||||
expect(config.lineLintRules.length).toEqual(5)
|
expect(config.lineLintRules.length).toEqual(expectedLineLintRulesCount)
|
||||||
expect(config.pathLintRules.length).toEqual(2)
|
expect(config.pathLintRules.length).toEqual(expectedPathLintRulesCount)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user