Major refactoring using ESLint with rules from AirBnb and Vue. Enable most of the ESLint rules and do necessary linting in the code. Also add more information for rules that are disabled to describe what they are and why they are disabled. Allow logging (`console.log`) in test files, and in development mode (e.g. when working with `npm run serve`), but disable it when environment is production (as pre-configured by Vue). Also add flag (`--mode production`) in `lint:eslint` command so production linting is executed earlier in lifecycle. Disable rules that requires a separate work. Such as ESLint rules that are broken in TypeScript: no-useless-constructor (eslint/eslint#14118) and no-shadow (eslint/eslint#13014).
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import 'mocha';
|
|
import { expect } from 'chai';
|
|
import { BatchBuilder } from '@/application/Context/State/Code/Generation/Languages/BatchBuilder';
|
|
|
|
describe('BatchBuilder', () => {
|
|
class BatchBuilderRevealer extends BatchBuilder {
|
|
public getCommentDelimiter(): string {
|
|
return super.getCommentDelimiter();
|
|
}
|
|
|
|
public writeStandardOut(text: string): string {
|
|
return super.writeStandardOut(text);
|
|
}
|
|
}
|
|
describe('getCommentDelimiter', () => {
|
|
it('returns expected', () => {
|
|
// arrange
|
|
const expected = '::';
|
|
const sut = new BatchBuilderRevealer();
|
|
// act
|
|
const actual = sut.getCommentDelimiter();
|
|
// assert
|
|
expect(expected).to.equal(actual);
|
|
});
|
|
});
|
|
describe('writeStandardOut', () => {
|
|
const testData = [
|
|
{
|
|
name: 'plain text',
|
|
text: 'test',
|
|
expected: 'echo test',
|
|
},
|
|
{
|
|
name: 'text with ampersand',
|
|
text: 'a & b',
|
|
expected: 'echo a ^& b',
|
|
},
|
|
{
|
|
name: 'text with percent sign',
|
|
text: '90%',
|
|
expected: 'echo 90%%',
|
|
},
|
|
{
|
|
name: 'text with multiple ampersands and percent signs',
|
|
text: 'Me&you in % ? You & me = 0%',
|
|
expected: 'echo Me^&you in %% ? You ^& me = 0%%',
|
|
},
|
|
];
|
|
for (const test of testData) {
|
|
it(test.name, () => {
|
|
// arrange
|
|
const sut = new BatchBuilderRevealer();
|
|
// act
|
|
const actual = sut.writeStandardOut(test.text);
|
|
// assert
|
|
expect(test.expected).to.equal(actual);
|
|
});
|
|
}
|
|
});
|
|
});
|