generated from maxisam/github-ts-action-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
77 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import * as problemMatcherJson from '../src/problem-matcher.json'; | ||
|
||
const problemMatcher = problemMatcherJson.problemMatcher[0]; | ||
|
||
function matchResults(output: string[], regexp: RegExp): RegExpExecArray[] { | ||
return output.map(line => regexp.exec(line)).filter(match => match) as RegExpExecArray[]; | ||
} | ||
|
||
describe('problemMatcher', () => { | ||
it('has the correct owner', () => { | ||
expect(problemMatcher.owner).toEqual('dotnet-format-plus'); | ||
}); | ||
|
||
it('has one pattern', () => { | ||
expect(problemMatcher.pattern.length).toEqual(1); | ||
}); | ||
|
||
describe('pattern', () => { | ||
const reportOutput = [ | ||
"/path/file.cs(15,2): error WHITESPACE: Fix whitespace formatting. Insert '\t'. [/path/project.csproj]", | ||
"/path/file.cs(15,3): error WHITESPACE: Fix whitespace formatting. Replace 4 characters with '\n\t\t\t'. [/path/project.csproj]", | ||
"/path/file.cs(16,84): error WHITESPACE: Fix whitespace formatting. Replace 4 characters with '\n\t\t\t'. [/path/project.csproj]" | ||
]; | ||
|
||
let pattern: any; | ||
let results: RegExpExecArray[]; | ||
|
||
beforeEach(() => { | ||
pattern = problemMatcher.pattern[0]; | ||
|
||
const regexp = new RegExp(pattern.regexp); | ||
|
||
results = matchResults(reportOutput, regexp); | ||
}); | ||
|
||
it('matches violations', () => { | ||
expect(results.length).toEqual(3); | ||
}); | ||
|
||
it('matches violation details', () => { | ||
expect(results[0][pattern.file]).toEqual('/path/file.cs'); | ||
expect(results[0][pattern.line]).toEqual('15'); | ||
expect(results[0][pattern.column]).toEqual('2'); | ||
expect(results[0][pattern.message]).toEqual("Fix whitespace formatting. Insert '\t'."); | ||
expect(results[0][pattern.severity]).toEqual('error'); | ||
expect(results[0][pattern.code]).toEqual('WHITESPACE'); | ||
|
||
expect(results[1][pattern.file]).toEqual('/path/file.cs'); | ||
expect(results[1][pattern.line]).toEqual('15'); | ||
expect(results[1][pattern.column]).toEqual('3'); | ||
expect(results[1][pattern.message]).toEqual("Fix whitespace formatting. Replace 4 characters with '\n\t\t\t'."); | ||
|
||
expect(results[2][pattern.file]).toEqual('/path/file.cs'); | ||
expect(results[2][pattern.line]).toEqual('16'); | ||
expect(results[2][pattern.column]).toEqual('84'); | ||
expect(results[2][pattern.message]).toEqual("Fix whitespace formatting. Replace 4 characters with '\n\t\t\t'."); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2022" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, | ||
"module": "ES2022" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, | ||
"outDir": "./lib" /* Redirect output structure to the directory. */, | ||
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, | ||
"strict": true /* Enable all strict type-checking options. */, | ||
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, | ||
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, | ||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, | ||
"forceConsistentCasingInFileNames": false, | ||
"noUnusedParameters": true, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true | ||
}, | ||
"exclude": [ | ||
"node_modules", | ||
"**/*.test.ts" | ||
] | ||
} | ||
"compilerOptions": { | ||
"target": "ES2022" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, | ||
"module": "ES2022" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, | ||
"outDir": "./lib" /* Redirect output structure to the directory. */, | ||
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, | ||
"strict": true /* Enable all strict type-checking options. */, | ||
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, | ||
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, | ||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, | ||
"forceConsistentCasingInFileNames": false, | ||
"noUnusedParameters": true, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true, | ||
"resolveJsonModule": true | ||
}, | ||
"exclude": ["node_modules", "**/*.test.ts"] | ||
} |