mirror of
https://github.com/sasjs/lint.git
synced 2026-01-17 09:10:06 +00:00
test(*): removed extra lineEndings
This commit is contained in:
@@ -6,7 +6,7 @@ import { LintConfig } from '../types'
|
|||||||
describe('formatFile', () => {
|
describe('formatFile', () => {
|
||||||
it('should fix linting issues in a given file', async () => {
|
it('should fix linting issues in a given file', async () => {
|
||||||
const content = `%macro somemacro(); \n%put 'hello';\n%mend;`
|
const content = `%macro somemacro(); \n%put 'hello';\n%mend;`
|
||||||
const expectedContent = `/**\n @file\n @brief <Your brief here>\n <h4> SAS Macros </h4>\n**/\n%macro somemacro();\n%put 'hello';\n%mend somemacro;\n`
|
const expectedContent = `/**\n @file\n @brief <Your brief here>\n <h4> SAS Macros </h4>\n**/\n%macro somemacro();\n%put 'hello';\n%mend somemacro;`
|
||||||
await createFile(path.join(__dirname, 'format-file-test.sas'), content)
|
await createFile(path.join(__dirname, 'format-file-test.sas'), content)
|
||||||
|
|
||||||
await formatFile(path.join(__dirname, 'format-file-test.sas'))
|
await formatFile(path.join(__dirname, 'format-file-test.sas'))
|
||||||
@@ -19,7 +19,7 @@ describe('formatFile', () => {
|
|||||||
|
|
||||||
it('should use the provided config if available', async () => {
|
it('should use the provided config if available', async () => {
|
||||||
const content = `%macro somemacro(); \n%put 'hello';\n%mend;`
|
const content = `%macro somemacro(); \n%put 'hello';\n%mend;`
|
||||||
const expectedContent = `/**\r\n @file\r\n @brief <Your brief here>\r\n <h4> SAS Macros </h4>\r\n**/\r\n%macro somemacro();\r\n%put 'hello';\r\n%mend somemacro;\r\n`
|
const expectedContent = `/**\r\n @file\r\n @brief <Your brief here>\r\n <h4> SAS Macros </h4>\r\n**/\r\n%macro somemacro();\r\n%put 'hello';\r\n%mend somemacro;`
|
||||||
await createFile(path.join(__dirname, 'format-file-config.sas'), content)
|
await createFile(path.join(__dirname, 'format-file-config.sas'), content)
|
||||||
|
|
||||||
await formatFile(
|
await formatFile(
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
describe('formatFolder', () => {
|
describe('formatFolder', () => {
|
||||||
it('should fix linting issues in a given folder', async () => {
|
it('should fix linting issues in a given folder', async () => {
|
||||||
const content = `%macro somemacro(); \n%put 'hello';\n%mend;`
|
const content = `%macro somemacro(); \n%put 'hello';\n%mend;`
|
||||||
const expectedContent = `/**\n @file\n @brief <Your brief here>\n <h4> SAS Macros </h4>\n**/\n%macro somemacro();\n%put 'hello';\n%mend somemacro;\n`
|
const expectedContent = `/**\n @file\n @brief <Your brief here>\n <h4> SAS Macros </h4>\n**/\n%macro somemacro();\n%put 'hello';\n%mend somemacro;`
|
||||||
await createFolder(path.join(__dirname, 'format-folder-test'))
|
await createFolder(path.join(__dirname, 'format-folder-test'))
|
||||||
await createFile(
|
await createFile(
|
||||||
path.join(__dirname, 'format-folder-test', 'format-folder-test.sas'),
|
path.join(__dirname, 'format-folder-test', 'format-folder-test.sas'),
|
||||||
@@ -29,7 +29,7 @@ describe('formatFolder', () => {
|
|||||||
|
|
||||||
it('should fix linting issues in subfolders of a given folder', async () => {
|
it('should fix linting issues in subfolders of a given folder', async () => {
|
||||||
const content = `%macro somemacro(); \n%put 'hello';\n%mend;`
|
const content = `%macro somemacro(); \n%put 'hello';\n%mend;`
|
||||||
const expectedContent = `/**\n @file\n @brief <Your brief here>\n <h4> SAS Macros </h4>\n**/\n%macro somemacro();\n%put 'hello';\n%mend somemacro;\n`
|
const expectedContent = `/**\n @file\n @brief <Your brief here>\n <h4> SAS Macros </h4>\n**/\n%macro somemacro();\n%put 'hello';\n%mend somemacro;`
|
||||||
await createFolder(path.join(__dirname, 'format-folder-test'))
|
await createFolder(path.join(__dirname, 'format-folder-test'))
|
||||||
await createFolder(path.join(__dirname, 'subfolder'))
|
await createFolder(path.join(__dirname, 'subfolder'))
|
||||||
await createFile(
|
await createFile(
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ jest.mock('../utils/getProjectRoot')
|
|||||||
describe('formatProject', () => {
|
describe('formatProject', () => {
|
||||||
it('should format files in the current project', async () => {
|
it('should format files in the current project', async () => {
|
||||||
const content = `%macro somemacro(); \n%put 'hello';\n%mend;`
|
const content = `%macro somemacro(); \n%put 'hello';\n%mend;`
|
||||||
const expectedContent = `/**\n @file\n @brief <Your brief here>\n <h4> SAS Macros </h4>\n**/\n%macro somemacro();\n%put 'hello';\n%mend somemacro;\n`
|
const expectedContent = `/**\n @file\n @brief <Your brief here>\n <h4> SAS Macros </h4>\n**/\n%macro somemacro();\n%put 'hello';\n%mend somemacro;`
|
||||||
await createFolder(path.join(__dirname, 'format-project-test'))
|
await createFolder(path.join(__dirname, 'format-project-test'))
|
||||||
await createFile(
|
await createFile(
|
||||||
path.join(__dirname, 'format-project-test', 'format-project-test.sas'),
|
path.join(__dirname, 'format-project-test', 'format-project-test.sas'),
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ describe('formatText', () => {
|
|||||||
@brief <Your brief here>
|
@brief <Your brief here>
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
**/\n%macro test
|
**/\n%macro test
|
||||||
%put 'hello';\n%mend test;\n`
|
%put 'hello';\n%mend test;`
|
||||||
|
|
||||||
const output = await formatText(text)
|
const output = await formatText(text)
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ describe('formatText', () => {
|
|||||||
)
|
)
|
||||||
const text = `%macro test\n %put 'hello';\r\n%mend; `
|
const text = `%macro test\n %put 'hello';\r\n%mend; `
|
||||||
|
|
||||||
const expectedOutput = `/**\r\n @file\r\n @brief <Your brief here>\r\n <h4> SAS Macros </h4>\r\n**/\r\n%macro test\r\n %put 'hello';\r\n%mend test;\r\n`
|
const expectedOutput = `/**\r\n @file\r\n @brief <Your brief here>\r\n <h4> SAS Macros </h4>\r\n**/\r\n%macro test\r\n %put 'hello';\r\n%mend test;`
|
||||||
|
|
||||||
const output = await formatText(text)
|
const output = await formatText(text)
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ describe('parseMacros', () => {
|
|||||||
name: 'test',
|
name: 'test',
|
||||||
declaration: '%macro test;',
|
declaration: '%macro test;',
|
||||||
termination: '%mend',
|
termination: '%mend',
|
||||||
|
declarationTrimmedStatement: '%macro test',
|
||||||
|
terminationTrimmedStatement: '%mend',
|
||||||
startLineNumber: 1,
|
startLineNumber: 1,
|
||||||
endLineNumber: 3,
|
endLineNumber: 3,
|
||||||
parentMacro: '',
|
parentMacro: '',
|
||||||
@@ -38,6 +40,8 @@ describe('parseMacros', () => {
|
|||||||
name: 'foo',
|
name: 'foo',
|
||||||
declaration: '%macro foo;',
|
declaration: '%macro foo;',
|
||||||
termination: '%mend;',
|
termination: '%mend;',
|
||||||
|
declarationTrimmedStatement: '%macro foo',
|
||||||
|
terminationTrimmedStatement: '%mend',
|
||||||
startLineNumber: 1,
|
startLineNumber: 1,
|
||||||
endLineNumber: 3,
|
endLineNumber: 3,
|
||||||
parentMacro: '',
|
parentMacro: '',
|
||||||
@@ -49,6 +53,8 @@ describe('parseMacros', () => {
|
|||||||
name: 'bar',
|
name: 'bar',
|
||||||
declaration: '%macro bar();',
|
declaration: '%macro bar();',
|
||||||
termination: '%mend bar;',
|
termination: '%mend bar;',
|
||||||
|
declarationTrimmedStatement: '%macro bar()',
|
||||||
|
terminationTrimmedStatement: '%mend bar',
|
||||||
startLineNumber: 4,
|
startLineNumber: 4,
|
||||||
endLineNumber: 6,
|
endLineNumber: 6,
|
||||||
parentMacro: '',
|
parentMacro: '',
|
||||||
@@ -73,6 +79,8 @@ describe('parseMacros', () => {
|
|||||||
name: 'test',
|
name: 'test',
|
||||||
declaration: '%macro test()',
|
declaration: '%macro test()',
|
||||||
termination: '%mend test',
|
termination: '%mend test',
|
||||||
|
declarationTrimmedStatement: '%macro test()',
|
||||||
|
terminationTrimmedStatement: '%mend test',
|
||||||
startLineNumber: 1,
|
startLineNumber: 1,
|
||||||
endLineNumber: 6,
|
endLineNumber: 6,
|
||||||
parentMacro: '',
|
parentMacro: '',
|
||||||
@@ -84,6 +92,8 @@ describe('parseMacros', () => {
|
|||||||
name: 'test2',
|
name: 'test2',
|
||||||
declaration: ' %macro test2',
|
declaration: ' %macro test2',
|
||||||
termination: ' %mend',
|
termination: ' %mend',
|
||||||
|
declarationTrimmedStatement: '%macro test2',
|
||||||
|
terminationTrimmedStatement: '%mend',
|
||||||
startLineNumber: 3,
|
startLineNumber: 3,
|
||||||
endLineNumber: 5,
|
endLineNumber: 5,
|
||||||
parentMacro: 'test',
|
parentMacro: 'test',
|
||||||
|
|||||||
Reference in New Issue
Block a user