Migrate unit/integration tests to Vitest with Vite
As part of transition to Vue 3.0 and Vite (#230), this commit facilitates the shift towards building rest of the application using Vite. By doing so, it eliminates reliance on outdated Electron building system that offered limited control, blocking desktop builds (#233). Changes include: - Introduce Vite with Vue 2.0 plugin for test execution. - Remove `mocha`, `chai` and other related dependencies. - Adjust test to Vitest syntax. - Revise and update `tests.md` to document the changes. - Add `@modyfi/vite-plugin-yaml` plugin to be able to use yaml file depended logic on test files, replacing previous webpack behavior. - Fix failing tests that are revealed by Vitest due to unhandled errors and lack of assertments. - Remove the test that depends on Vue CLI populating `process.env`. - Use `jsdom` for unit test environment, adding it to dependency to `package.json` as project now depends on it and it was not specified even though `package-lock.json` included it.
This commit is contained in:
@@ -42,9 +42,6 @@ module.exports = {
|
||||
'**/__tests__/*.{j,t}s?(x)',
|
||||
'**/tests/unit/**/*.spec.{j,t}s?(x)',
|
||||
],
|
||||
env: {
|
||||
mocha: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/tests/**/*.{j,t}s?(x)'],
|
||||
|
||||
110
docs/tests.md
110
docs/tests.md
@@ -5,74 +5,76 @@ There are different types of tests executed:
|
||||
1. [Unit tests](#unit-tests)
|
||||
2. [Integration tests](#integration-tests)
|
||||
3. [End-to-end (E2E) tests](#e2e-tests)
|
||||
4. [Automated checks](#automated-checks)
|
||||
|
||||
Common aspects for all tests:
|
||||
## Unit and integration tests
|
||||
|
||||
- They use [Mocha](https://mochajs.org/) and [Chai](https://www.chaijs.com/).
|
||||
- Their files end with `.spec.{ts|js}` suffix.
|
||||
|
||||
💡 You can use path/module alias `@/tests` in import statements.
|
||||
|
||||
## Unit tests
|
||||
|
||||
- Unit tests test each component in isolation.
|
||||
- All unit tests goes under [`./tests/unit`](./../tests/unit).
|
||||
- They rely on [stubs](./../tests/unit/shared/Stubs) for isolation.
|
||||
- Unit tests include also Vue component tests using `@vue/test-utils`.
|
||||
|
||||
### Unit tests structure
|
||||
|
||||
- [`./src/`](./../src/)
|
||||
- Includes source code that unit tests will test.
|
||||
- [`./tests/unit/`](./../tests/unit/)
|
||||
- Includes test code.
|
||||
- Tests follow same folder structure as [`./src/`](./../src).
|
||||
- E.g. if system under test lies in [`./src/application/ApplicationFactory.ts`](./../src/application/ApplicationFactory.ts) then its tests would be in test would be at [`./tests/unit/application/ApplicationFactory.spec.ts`](./../tests/unit/application/ApplicationFactory.spec.ts).
|
||||
- [`shared/`](./../tests/unit/shared/)
|
||||
- Includes common functionality that's shared across unit tests.
|
||||
- [`Assertions/`](./../tests/unit/shared/Assertions):
|
||||
- Common assertions that extend [Chai Assertion Library](https://www.chaijs.com/).
|
||||
- Asserting functions should start with `expect` prefix.
|
||||
- [`TestCases/`](./../tests/unit/shared/TestCases/)
|
||||
- Shared test cases.
|
||||
- Functions that calls `it()` from [Mocha test framework](https://mochajs.org/) should have `it` prefix.
|
||||
- E.g. `itEachAbsentCollectionValue()`.
|
||||
- [`Stubs/`](./../tests/unit/shared/Stubs)
|
||||
- Includes stubs to be able to test components in isolation.
|
||||
- Stubs have minimal and dummy behavior to be functional, they may also have spying or mocking functions.
|
||||
|
||||
### Unit tests naming
|
||||
|
||||
- Each test suite first describe the system under test.
|
||||
- E.g. tests for class `Application.ts` are all inside `Application.spec.ts`.
|
||||
- `describe` blocks tests for same function (if applicable).
|
||||
- E.g. test for `run()` are inside `describe('run', () => ..)`.
|
||||
- They utilize [Vitest](https://vitest.dev/).
|
||||
- Test files are suffixed with `.spec.ts`.
|
||||
|
||||
### Act, arrange, assert
|
||||
|
||||
- Tests use act, arrange and assert (AAA) pattern when applicable.
|
||||
- Tests implement the act, arrange, and assert (AAA) pattern.
|
||||
- **Arrange**
|
||||
- Sets up the test case.
|
||||
- Starts with comment line `// arrange`.
|
||||
- Sets up the test scenario and environment.
|
||||
- Begins with comment line `// arrange`.
|
||||
- **Act**
|
||||
- Executes the actual test.
|
||||
- Starts with comment line `// act`.
|
||||
- Begins with comment line `// act`.
|
||||
- **Assert**
|
||||
- Elicit some sort of expectation.
|
||||
- Starts with comment line `// assert`.
|
||||
- Sets an expectation for the test's outcome.
|
||||
- Begins with comment line `// assert`.
|
||||
|
||||
## Integration tests
|
||||
### Unit tests
|
||||
|
||||
- Tests functionality of a component in combination with others (not isolated).
|
||||
- Ensure dependencies to third parties work as expected.
|
||||
- Defined in [./tests/integration](./../tests/integration).
|
||||
- Evaluate individual components in isolation.
|
||||
- Located in [`./tests/unit`](./../tests/unit).
|
||||
- Achieve isolation using [stubs](./../tests/unit/shared/Stubs).
|
||||
- Include Vue component tests, enabled by `@vue/test-utils`.
|
||||
|
||||
#### Unit tests naming
|
||||
|
||||
- Test suites start with a description of the component or system under test.
|
||||
- E.g., tests for `Application.ts` are contained in `Application.spec.ts`.
|
||||
- Whenever possible, `describe` blocks group tests of the same function.
|
||||
- E.g., tests for `run()` are inside `describe('run', () => ...)`.
|
||||
|
||||
### Integration tests
|
||||
|
||||
- Assess the combined functionality of components.
|
||||
- They verify that third-party dependencies function as anticipated.
|
||||
|
||||
## E2E tests
|
||||
|
||||
- Test the functionality and performance of a running application.
|
||||
- Vue CLI plugin [`e2e-cypress`](https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-plugin-e2e-cypress#readme) configures E2E tests.
|
||||
- Test names and folders have logical structure based on tests executed.
|
||||
- The structure is following:
|
||||
- Examine the live web application's functionality and performance.
|
||||
- Configured with the Vue CLI plugin [`e2e-cypress`](https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-plugin-e2e-cypress#readme).
|
||||
|
||||
## Automated checks
|
||||
|
||||
These checks validate various qualities like runtime execution, building process, security testing, etc.
|
||||
|
||||
- Use [various tools](./../package.json) and [scripts](./../scripts).
|
||||
- Are automatically executed as [GitHub workflows](./../.github/workflows).
|
||||
|
||||
## Tests structure
|
||||
|
||||
- [`package.json`](./../package.json): Defines test commands and includes tools used in tests.
|
||||
- [`vite.config.ts`](./../vite.config.ts): Configures `vitest` for unit and integration tests.
|
||||
- [`./src/`](./../src/): Contains the source code subject to testing.
|
||||
- **[`./tests/bootstrap/setup.ts`](./../tests/bootstrap/setup.ts)**: Initializes tests.
|
||||
- **[`./tests/unit/`](./../tests/unit/)**
|
||||
- Stores unit test code.
|
||||
- The directory structure mirrors [`./src/`](./../src).
|
||||
- E.g., tests for [`./src/application/ApplicationFactory.ts`](./../src/application/ApplicationFactory.ts) reside in [`./tests/unit/application/ApplicationFactory.spec.ts`](./../tests/unit/application/ApplicationFactory.spec.ts).
|
||||
- [`shared/`](./../tests/unit/shared/)
|
||||
- Contains shared unit test functionalities.
|
||||
- [`Assertions/`](./../tests/unit/shared/Assertions): Contains common assertion functions, prefixed with `expect`.
|
||||
- [`TestCases/`](./../tests/unit/shared/TestCases/)
|
||||
- Shared test cases.
|
||||
- Functions that calls `it()` from [Vitest](https://vitest.dev/) should have `it` prefix.
|
||||
- [`Stubs/`](./../tests/unit/shared/Stubs): Maintains stubs for component isolation, equipped with basic functionalities and, when necessary, spying or mocking capabilities.
|
||||
- **[`./tests/integration/`](./../tests/integration/)**: Contains integration test files.
|
||||
- **[`./tests/e2e/`](./../tests/e2e/)**
|
||||
- [`cypress.config.ts`](./../cypress.config.ts): Cypress configuration file.
|
||||
- [`./tests/e2e/`](./../tests/e2e/): Base Cypress folder.
|
||||
- [`/specs/`](./../tests/e2e/specs/): Test files named with `.spec.js` extension.
|
||||
|
||||
15038
package-lock.json
generated
15038
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
15
package.json
15
package.json
@@ -9,7 +9,8 @@
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"test:unit": "vue-cli-service test:unit --include ./tests/bootstrap/setup.ts",
|
||||
"test:unit": "vitest run --dir tests/unit --environment jsdom",
|
||||
"test:integration": "vitest run --dir tests/integration --environment node",
|
||||
"test:e2e": "vue-cli-service test:e2e",
|
||||
"lint": "npm run lint:md && npm run lint:md:consistency && npm run lint:md:relative-urls && npm run lint:eslint && npm run lint:yaml",
|
||||
"create-icons": "node img/logo-update.mjs",
|
||||
@@ -21,8 +22,7 @@
|
||||
"lint:md:relative-urls": "remark . --frail --use remark-validate-links",
|
||||
"lint:yaml": "yamllint **/*.yaml --ignore=node_modules/**/*.yaml",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"postuninstall": "electron-builder install-app-deps",
|
||||
"test:integration": "vue-cli-service test:unit \"tests/integration/**/*.spec.ts\" --include ./tests/bootstrap/setup.ts"
|
||||
"postuninstall": "electron-builder install-app-deps"
|
||||
},
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
@@ -45,23 +45,21 @@
|
||||
"vue": "^2.7.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@modyfi/vite-plugin-yaml": "^1.0.4",
|
||||
"@rushstack/eslint-patch": "^1.3.2",
|
||||
"@types/ace": "^0.0.48",
|
||||
"@types/chai": "^4.3.5",
|
||||
"@types/file-saver": "^2.0.5",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
||||
"@typescript-eslint/parser": "^5.62.0",
|
||||
"@vitejs/plugin-vue2": "^2.2.0",
|
||||
"@vue/cli-plugin-babel": "~5.0.8",
|
||||
"@vue/cli-plugin-e2e-cypress": "~5.0.8",
|
||||
"@vue/cli-plugin-eslint": "~5.0.8",
|
||||
"@vue/cli-plugin-typescript": "~5.0.8",
|
||||
"@vue/cli-plugin-unit-mocha": "~5.0.8",
|
||||
"@vue/cli-service": "~5.0.8",
|
||||
"@vue/eslint-config-airbnb-with-typescript": "^7.0.0",
|
||||
"@vue/eslint-config-typescript": "^11.0.3",
|
||||
"@vue/test-utils": "^1.3.6",
|
||||
"chai": "^4.3.7",
|
||||
"cypress": "^12.17.2",
|
||||
"electron": "^25.3.2",
|
||||
"electron-builder": "^24.6.3",
|
||||
@@ -75,6 +73,7 @@
|
||||
"eslint-plugin-vuejs-accessibility": "^1.2.0",
|
||||
"icon-gen": "^3.0.1",
|
||||
"js-yaml-loader": "^1.2.2",
|
||||
"jsdom": "^22.1.0",
|
||||
"markdownlint-cli": "^0.35.0",
|
||||
"remark-cli": "^11.0.0",
|
||||
"remark-lint-no-dead-urls": "^1.1.0",
|
||||
@@ -86,6 +85,8 @@
|
||||
"ts-loader": "^9.4.4",
|
||||
"tslib": "~2.4.0",
|
||||
"typescript": "~4.6.2",
|
||||
"vite": "^4.4.9",
|
||||
"vitest": "^0.34.2",
|
||||
"vue-cli-plugin-electron-builder": "^3.0.0-alpha.4",
|
||||
"yaml-lint": "^1.7.0"
|
||||
},
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Application } from '@/domain/Application';
|
||||
import { parseCategoryCollection } from './CategoryCollectionParser';
|
||||
|
||||
export function parseApplication(
|
||||
parser = CategoryCollectionParser,
|
||||
parser: CategoryCollectionParserType = parseCategoryCollection,
|
||||
processEnv: NodeJS.ProcessEnv = process.env,
|
||||
collectionsData = PreParsedCollections,
|
||||
): IApplication {
|
||||
@@ -24,16 +24,12 @@ export function parseApplication(
|
||||
export type CategoryCollectionParserType
|
||||
= (file: CollectionData, info: IProjectInformation) => ICategoryCollection;
|
||||
|
||||
const CategoryCollectionParser: CategoryCollectionParserType = (file, info) => {
|
||||
return parseCategoryCollection(file, info);
|
||||
};
|
||||
|
||||
const PreParsedCollections: readonly CollectionData [] = [
|
||||
WindowsData, MacOsData, LinuxData,
|
||||
];
|
||||
|
||||
function validateCollectionsData(collections: readonly CollectionData[]) {
|
||||
if (!collections || !collections.length) {
|
||||
if (!collections?.length) {
|
||||
throw new Error('missing collections');
|
||||
}
|
||||
if (collections.some((collection) => !collection)) {
|
||||
|
||||
3
tests/README.md
Normal file
3
tests/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# tests
|
||||
|
||||
See [`tests.md`](./../docs/tests.md)
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'mocha';
|
||||
import { afterEach } from 'vitest';
|
||||
import { enableAutoDestroy } from '@vue/test-utils';
|
||||
|
||||
enableAutoDestroy(afterEach);
|
||||
|
||||
@@ -3,7 +3,6 @@ module.exports = {
|
||||
'cypress',
|
||||
],
|
||||
env: {
|
||||
mocha: true,
|
||||
'cypress/globals': true,
|
||||
},
|
||||
rules: {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { parseApplication } from '@/application/Parser/ApplicationParser';
|
||||
|
||||
describe('ApplicationParser', () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { parseApplication } from '@/application/Parser/ApplicationParser';
|
||||
import { IApplication } from '@/domain/IApplication';
|
||||
import { IUrlStatus } from './StatusChecker/IUrlStatus';
|
||||
@@ -29,7 +28,7 @@ describe('collections', () => {
|
||||
// assert
|
||||
const deadUrls = results.filter((r) => r.code !== 200);
|
||||
expect(deadUrls).to.have.lengthOf(0, printUrls(deadUrls));
|
||||
}).timeout(testTimeoutInMs);
|
||||
}, testTimeoutInMs);
|
||||
});
|
||||
|
||||
function collectUniqueUrls(app: IApplication): string[] {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { parseApplication } from '@/application/Parser/ApplicationParser';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { createRenderer } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/Documentation/MarkdownRenderer';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ApplicationFactory, ApplicationGetterType } from '@/application/ApplicationFactory';
|
||||
import { ApplicationStub } from '@tests/unit/shared/Stubs/ApplicationStub';
|
||||
import { itEachAbsentObjectValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { scrambledEqual, sequenceEqual } from '@/application/Common/Array';
|
||||
import { itEachAbsentObjectValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
import { ComparerTestScenario } from './Array.ComparerTestScenario';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// eslint-disable-next-line max-classes-per-file
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import {
|
||||
describe, it, afterEach, expect,
|
||||
} from 'vitest';
|
||||
import { CustomError, Environment } from '@/application/Common/CustomError';
|
||||
|
||||
describe('CustomError', () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
getEnumNames, getEnumValues, createEnumParser, assertInRange,
|
||||
} from '@/application/Common/Enum';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { EnumType } from '@/application/Common/Enum';
|
||||
import { itEachAbsentObjectValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ScriptingLanguage } from '@/domain/ScriptingLanguage';
|
||||
import { ScriptingLanguageFactory } from '@/application/Common/ScriptingLanguage/ScriptingLanguageFactory';
|
||||
import { EnumRangeTestRunner } from '@tests/unit/application/Common/EnumRangeTestRunner';
|
||||
@@ -58,8 +57,12 @@ describe('ScriptingLanguageFactory', () => {
|
||||
const sut = new ScriptingLanguageConcrete();
|
||||
const runner = new ScriptingLanguageFactoryTestRunner();
|
||||
// act
|
||||
sut.registerGetter(ScriptingLanguage.batchfile, () => 1);
|
||||
sut.registerGetter(ScriptingLanguage.batchfile, () => ScriptingLanguage.batchfile);
|
||||
sut.registerGetter(ScriptingLanguage.shellscript, () => ScriptingLanguage.shellscript);
|
||||
// assert
|
||||
runner.testCreateMethod(sut);
|
||||
runner
|
||||
.expectValue(ScriptingLanguage.shellscript, ScriptingLanguage.shellscript)
|
||||
.expectValue(ScriptingLanguage.batchfile, ScriptingLanguage.batchfile)
|
||||
.testCreateMethod(sut);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,29 +1,45 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { IScriptingLanguageFactory } from '@/application/Common/ScriptingLanguage/IScriptingLanguageFactory';
|
||||
import { ScriptingLanguage } from '@/domain/ScriptingLanguage';
|
||||
import { EnumRangeTestRunner } from '@tests/unit/application/Common/EnumRangeTestRunner';
|
||||
|
||||
export class ScriptingLanguageFactoryTestRunner<T> {
|
||||
private expectedTypes = new Map<ScriptingLanguage, T>();
|
||||
type Constructible<T = object> = new (...args: unknown[]) => T;
|
||||
|
||||
public expect(language: ScriptingLanguage, resultType: T) {
|
||||
this.expectedTypes.set(language, resultType);
|
||||
export class ScriptingLanguageFactoryTestRunner<T> {
|
||||
private expectedLanguageTypes = new Map<ScriptingLanguage, Constructible<T>>();
|
||||
|
||||
private expectedValues = new Map<ScriptingLanguage, T>();
|
||||
|
||||
public expectInstance(language: ScriptingLanguage, resultType: Constructible<T>) {
|
||||
this.expectedLanguageTypes.set(language, resultType);
|
||||
return this;
|
||||
}
|
||||
|
||||
public expectValue(language: ScriptingLanguage, resultType: T) {
|
||||
this.expectedValues.set(language, resultType);
|
||||
return this;
|
||||
}
|
||||
|
||||
public testCreateMethod(sut: IScriptingLanguageFactory<T>) {
|
||||
if (!sut) { throw new Error('missing sut'); }
|
||||
testLanguageValidation(sut);
|
||||
testExpectedInstanceTypes(sut, this.expectedTypes);
|
||||
if (this.expectedLanguageTypes.size) {
|
||||
testExpectedInstanceTypes(sut, this.expectedLanguageTypes);
|
||||
}
|
||||
if (this.expectedValues.size) {
|
||||
testExpectedValues(sut, this.expectedValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testExpectedInstanceTypes<T>(
|
||||
sut: IScriptingLanguageFactory<T>,
|
||||
expectedTypes: Map<ScriptingLanguage, T>,
|
||||
expectedTypes: Map<ScriptingLanguage, Constructible<T>>,
|
||||
) {
|
||||
describe('create returns expected instances', () => {
|
||||
if (!expectedTypes?.size) {
|
||||
throw new Error('No expected types provided.');
|
||||
}
|
||||
describe('`create` creates expected instances', () => {
|
||||
// arrange
|
||||
for (const language of expectedTypes.keys()) {
|
||||
it(ScriptingLanguage[language], () => {
|
||||
@@ -37,8 +53,29 @@ function testExpectedInstanceTypes<T>(
|
||||
});
|
||||
}
|
||||
|
||||
function testExpectedValues<T>(
|
||||
sut: IScriptingLanguageFactory<T>,
|
||||
expectedValues: Map<ScriptingLanguage, T>,
|
||||
) {
|
||||
if (!expectedValues?.size) {
|
||||
throw new Error('No expected values provided.');
|
||||
}
|
||||
describe('`create` creates expected values', () => {
|
||||
// arrange
|
||||
for (const language of expectedValues.keys()) {
|
||||
it(ScriptingLanguage[language], () => {
|
||||
// act
|
||||
const expected = expectedValues.get(language);
|
||||
const result = sut.create(language);
|
||||
// assert
|
||||
expect(result).to.equal(expected);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function testLanguageValidation<T>(sut: IScriptingLanguageFactory<T>) {
|
||||
describe('validates language', () => {
|
||||
describe('`create` validates language selection', () => {
|
||||
// arrange
|
||||
const validValue = ScriptingLanguage.batchfile;
|
||||
// act
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ApplicationContext } from '@/application/Context/ApplicationContext';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { ICategoryCollectionState } from '@/application/Context/State/ICategoryCollectionState';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { ICategoryCollection } from '@/domain/ICategoryCollection';
|
||||
import { buildContext } from '@/application/Context/ApplicationContextFactory';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { UserSelection } from '@/application/Context/State/Selection/UserSelection';
|
||||
import { ApplicationCode } from '@/application/Context/State/Code/ApplicationCode';
|
||||
import { CategoryCollectionState } from '@/application/Context/State/CategoryCollectionState';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { UserSelection } from '@/application/Context/State/Selection/UserSelection';
|
||||
import { ApplicationCode } from '@/application/Context/State/Code/ApplicationCode';
|
||||
import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { CodeChangedEvent } from '@/application/Context/State/Code/Event/CodeChangedEvent';
|
||||
import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript';
|
||||
import { ICodePosition } from '@/application/Context/State/Code/Position/ICodePosition';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { CodeBuilder } from '@/application/Context/State/Code/Generation/CodeBuilder';
|
||||
|
||||
describe('CodeBuilder', () => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { describe } from 'vitest';
|
||||
import { ScriptingLanguage } from '@/domain/ScriptingLanguage';
|
||||
import { ShellBuilder } from '@/application/Context/State/Code/Generation/Languages/ShellBuilder';
|
||||
import { BatchBuilder } from '@/application/Context/State/Code/Generation/Languages/BatchBuilder';
|
||||
@@ -7,7 +8,7 @@ import { ScriptingLanguageFactoryTestRunner } from '@tests/unit/application/Comm
|
||||
describe('CodeBuilderFactory', () => {
|
||||
const sut = new CodeBuilderFactory();
|
||||
const runner = new ScriptingLanguageFactoryTestRunner()
|
||||
.expect(ScriptingLanguage.shellscript, ShellBuilder)
|
||||
.expect(ScriptingLanguage.batchfile, BatchBuilder);
|
||||
.expectInstance(ScriptingLanguage.shellscript, ShellBuilder)
|
||||
.expectInstance(ScriptingLanguage.batchfile, BatchBuilder);
|
||||
runner.testCreateMethod(sut);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { BatchBuilder } from '@/application/Context/State/Code/Generation/Languages/BatchBuilder';
|
||||
|
||||
describe('BatchBuilder', () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ShellBuilder } from '@/application/Context/State/Code/Generation/Languages/ShellBuilder';
|
||||
|
||||
describe('ShellBuilder', () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { UserScriptGenerator } from '@/application/Context/State/Code/Generation/UserScriptGenerator';
|
||||
import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript';
|
||||
import { ICodeBuilderFactory } from '@/application/Context/State/Code/Generation/ICodeBuilderFactory';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { CodePosition } from '@/application/Context/State/Code/Position/CodePosition';
|
||||
|
||||
describe('CodePosition', () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { FilterChange } from '@/application/Context/State/Filter/Event/FilterChange';
|
||||
import { itEachAbsentObjectValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
import { FilterResultStub } from '@tests/unit/shared/Stubs/FilterResultStub';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { FilterResult } from '@/application/Context/State/Filter/FilterResult';
|
||||
import { CategoryStub } from '@tests/unit/shared/Stubs/CategoryStub';
|
||||
import { ScriptStub } from '@tests/unit/shared/Stubs/ScriptStub';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { IFilterResult } from '@/application/Context/State/Filter/IFilterResult';
|
||||
import { UserFilter } from '@/application/Context/State/Filter/UserFilter';
|
||||
import { CategoryStub } from '@tests/unit/shared/Stubs/CategoryStub';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ScriptStub } from '@tests/unit/shared/Stubs/ScriptStub';
|
||||
import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript';
|
||||
import { UserSelection } from '@/application/Context/State/Selection/UserSelection';
|
||||
import { CategoryStub } from '@tests/unit/shared/Stubs/CategoryStub';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { expect } from 'chai';
|
||||
import 'mocha';
|
||||
import { it, expect } from 'vitest';
|
||||
import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript';
|
||||
import { CategoryCollectionStub } from '@tests/unit/shared/Stubs/CategoryCollectionStub';
|
||||
import { CategoryStub } from '@tests/unit/shared/Stubs/CategoryStub';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { BrowserOsDetector } from '@/application/Environment/BrowserOs/BrowserOsDetector';
|
||||
import { itEachAbsentStringValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { IBrowserOsDetector } from '@/application/Environment/BrowserOs/IBrowserOsDetector';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { Environment, IEnvironmentVariables } from '@/application/Environment/Environment';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
/* eslint-disable max-classes-per-file */
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import type { CollectionData } from '@/application/collections/';
|
||||
import { parseProjectInformation } from '@/application/Parser/ProjectInformationParser';
|
||||
import { VueAppEnvironment, parseProjectInformation } from '@/application/Parser/ProjectInformationParser';
|
||||
import { CategoryCollectionParserType, parseApplication } from '@/application/Parser/ApplicationParser';
|
||||
import WindowsData from '@/application/collections/windows.yaml';
|
||||
import MacOsData from '@/application/collections/macos.yaml';
|
||||
@@ -28,10 +28,11 @@ describe('ApplicationParser', () => {
|
||||
const parser = new CategoryCollectionParserSpy()
|
||||
.setUpReturnValue(data, expected)
|
||||
.mockParser();
|
||||
const env = getProcessEnvironmentStub();
|
||||
const collections = [data];
|
||||
const sut = new ApplicationParserBuilder()
|
||||
.withCategoryCollectionParser(parser)
|
||||
.withCollectionsData([data]);
|
||||
// act
|
||||
const app = parseApplication(parser, env, collections);
|
||||
const app = sut.parseApplication();
|
||||
// assert
|
||||
const actual = app.getCollection(os);
|
||||
expect(expected).to.equal(actual);
|
||||
@@ -44,20 +45,10 @@ describe('ApplicationParser', () => {
|
||||
const expected = parseProjectInformation(env);
|
||||
const parserSpy = new CategoryCollectionParserSpy();
|
||||
const parserMock = parserSpy.mockParser();
|
||||
const sut = new ApplicationParserBuilder()
|
||||
.withCategoryCollectionParser(parserMock);
|
||||
// act
|
||||
const app = parseApplication(parserMock, env);
|
||||
// assert
|
||||
expect(expected).to.deep.equal(app.info);
|
||||
expect(parserSpy.arguments.map((arg) => arg.info).every((info) => info === expected));
|
||||
});
|
||||
it('defaults to process.env', () => {
|
||||
// arrange
|
||||
const { env } = process;
|
||||
const expected = parseProjectInformation(env);
|
||||
const parserSpy = new CategoryCollectionParserSpy();
|
||||
const parserMock = parserSpy.mockParser();
|
||||
// act
|
||||
const app = parseApplication(parserMock);
|
||||
const app = sut.parseApplication();
|
||||
// assert
|
||||
expect(expected).to.deep.equal(app.info);
|
||||
expect(parserSpy.arguments.map((arg) => arg.info).every((info) => info === expected));
|
||||
@@ -87,14 +78,15 @@ describe('ApplicationParser', () => {
|
||||
// act
|
||||
for (const testCase of testCases) {
|
||||
it(testCase.name, () => {
|
||||
const env = getProcessEnvironmentStub();
|
||||
let parserSpy = new CategoryCollectionParserSpy();
|
||||
for (let i = 0; i < testCase.input.length; i++) {
|
||||
parserSpy = parserSpy.setUpReturnValue(testCase.input[i], testCase.output[i]);
|
||||
}
|
||||
const parserMock = parserSpy.mockParser();
|
||||
const sut = new ApplicationParserBuilder()
|
||||
.withCategoryCollectionParser(parserSpy.mockParser())
|
||||
.withCollectionsData(testCase.input);
|
||||
// act
|
||||
const app = parseApplication(parserMock, env, testCase.input);
|
||||
const app = sut.parseApplication();
|
||||
// assert
|
||||
expect(app.collections).to.deep.equal(testCase.output);
|
||||
});
|
||||
@@ -104,9 +96,11 @@ describe('ApplicationParser', () => {
|
||||
// arrange
|
||||
const expected = [WindowsData, MacOsData, LinuxData];
|
||||
const parserSpy = new CategoryCollectionParserSpy();
|
||||
const parserMock = parserSpy.mockParser();
|
||||
const sut = new ApplicationParserBuilder()
|
||||
.withCollectionsData(undefined)
|
||||
.withCategoryCollectionParser(parserSpy.mockParser());
|
||||
// act
|
||||
parseApplication(parserMock);
|
||||
sut.parseApplication();
|
||||
// assert
|
||||
const actual = parserSpy.arguments.map((args) => args.data);
|
||||
expect(actual).to.deep.equal(expected);
|
||||
@@ -127,10 +121,10 @@ describe('ApplicationParser', () => {
|
||||
];
|
||||
for (const testCase of testCases) {
|
||||
it(testCase.name, () => {
|
||||
const parserMock = new CategoryCollectionParserSpy().mockParser();
|
||||
const env = getProcessEnvironmentStub();
|
||||
const sut = new ApplicationParserBuilder()
|
||||
.withCollectionsData(testCase.value);
|
||||
// act
|
||||
const act = () => parseApplication(parserMock, env, testCase.value);
|
||||
const act = () => sut.parseApplication();
|
||||
// assert
|
||||
expect(act).to.throw(testCase.expectedError);
|
||||
});
|
||||
@@ -140,6 +134,42 @@ describe('ApplicationParser', () => {
|
||||
});
|
||||
});
|
||||
|
||||
class ApplicationParserBuilder {
|
||||
private categoryCollectionParser: CategoryCollectionParserType = new CategoryCollectionParserSpy()
|
||||
.mockParser();
|
||||
|
||||
private environment: VueAppEnvironment = getProcessEnvironmentStub();
|
||||
|
||||
private collectionsData: CollectionData[] = [new CollectionDataStub()];
|
||||
|
||||
public withCategoryCollectionParser(
|
||||
categoryCollectionParser: CategoryCollectionParserType,
|
||||
): this {
|
||||
this.categoryCollectionParser = categoryCollectionParser;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withEnvironment(
|
||||
environment: VueAppEnvironment,
|
||||
): this {
|
||||
this.environment = environment;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withCollectionsData(collectionsData: CollectionData[]): this {
|
||||
this.collectionsData = collectionsData;
|
||||
return this;
|
||||
}
|
||||
|
||||
public parseApplication(): ReturnType<typeof parseApplication> {
|
||||
return parseApplication(
|
||||
this.categoryCollectionParser,
|
||||
this.environment,
|
||||
this.collectionsData,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CategoryCollectionParserSpy {
|
||||
public arguments = new Array<{
|
||||
data: CollectionData,
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { IEntity } from '@/infrastructure/Entity/IEntity';
|
||||
import { parseCategoryCollection } from '@/application/Parser/CategoryCollectionParser';
|
||||
import { parseCategory } from '@/application/Parser/CategoryParser';
|
||||
import { parseProjectInformation } from '@/application/Parser/ProjectInformationParser';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { RecommendationLevel } from '@/domain/RecommendationLevel';
|
||||
import { ScriptingDefinitionParser } from '@/application/Parser/ScriptingDefinition/ScriptingDefinitionParser';
|
||||
@@ -80,7 +78,7 @@ describe('CategoryCollectionParser', () => {
|
||||
it('parses scripting definition as expected', () => {
|
||||
// arrange
|
||||
const collection = new CollectionDataStub();
|
||||
const information = parseProjectInformation(process.env);
|
||||
const information = new ProjectInformationStub();
|
||||
const expected = new ScriptingDefinitionParser()
|
||||
.parse(collection.scripting, information);
|
||||
// act
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import type { CategoryData, CategoryOrScriptData } from '@/application/collections/';
|
||||
import { CategoryFactoryType, parseCategory } from '@/application/Parser/CategoryParser';
|
||||
import { parseScript } from '@/application/Parser/Script/ScriptParser';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import type { DocumentableData } from '@/application/collections/';
|
||||
import { parseDocs } from '@/application/Parser/DocumentationParser';
|
||||
import { itEachAbsentObjectValue, itEachAbsentStringValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { INodeDataErrorContext, NodeDataError } from '@/application/Parser/NodeValidation/NodeDataError';
|
||||
import { NodeDataErrorContextStub } from '@tests/unit/shared/Stubs/NodeDataErrorContextStub';
|
||||
import { NodeType } from '@/application/Parser/NodeValidation/NodeType';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { NodeDataError } from '@/application/Parser/NodeValidation/NodeDataError';
|
||||
import { NodeValidator } from '@/application/Parser/NodeValidation/NodeValidator';
|
||||
import { expectThrowsError } from '@tests/unit/shared/Assertions/ExpectThrowsError';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'mocha';
|
||||
import { describe, it } from 'vitest';
|
||||
import { NodeDataError, INodeDataErrorContext } from '@/application/Parser/NodeValidation/NodeDataError';
|
||||
import { NodeData } from '@/application/Parser/NodeValidation/NodeData';
|
||||
import { AbsentObjectTestCases, AbsentStringTestCases, itEachAbsentTestCase } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { VueAppEnvironmentKeys, parseProjectInformation } from '@/application/Parser/ProjectInformationParser';
|
||||
import { getProcessEnvironmentStub } from '@tests/unit/shared/Stubs/ProcessEnvironmentStub';
|
||||
import { IProjectInformation } from '@/domain/IProjectInformation';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ISyntaxFactory } from '@/application/Parser/Script/Validation/Syntax/ISyntaxFactory';
|
||||
import { ScriptingLanguage } from '@/domain/ScriptingLanguage';
|
||||
import { CategoryCollectionParseContext } from '@/application/Parser/Script/CategoryCollectionParseContext';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ExpressionPosition } from '@/application/Parser/Script/Compiler/Expressions/Expression/ExpressionPosition';
|
||||
import { ExpressionEvaluator, Expression } from '@/application/Parser/Script/Compiler/Expressions/Expression/Expression';
|
||||
import { IReadOnlyFunctionCallArgumentCollection } from '@/application/Parser/Script/Compiler/Function/Call/Argument/IFunctionCallArgumentCollection';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ExpressionEvaluationContext, IExpressionEvaluationContext } from '@/application/Parser/Script/Compiler/Expressions/Expression/ExpressionEvaluationContext';
|
||||
import { IReadOnlyFunctionCallArgumentCollection } from '@/application/Parser/Script/Compiler/Function/Call/Argument/IFunctionCallArgumentCollection';
|
||||
import { IPipelineCompiler } from '@/application/Parser/Script/Compiler/Expressions/Pipes/IPipelineCompiler';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ExpressionPosition } from '@/application/Parser/Script/Compiler/Expressions/Expression/ExpressionPosition';
|
||||
|
||||
describe('ExpressionPosition', () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ExpressionsCompiler } from '@/application/Parser/Script/Compiler/Expressions/ExpressionsCompiler';
|
||||
import { IExpressionParser } from '@/application/Parser/Script/Compiler/Expressions/Parser/IExpressionParser';
|
||||
import { ExpressionStub } from '@tests/unit/shared/Stubs/ExpressionStub';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { IExpression } from '@/application/Parser/Script/Compiler/Expressions/Expression/IExpression';
|
||||
import { IExpressionParser } from '@/application/Parser/Script/Compiler/Expressions/Parser/IExpressionParser';
|
||||
import { CompositeExpressionParser } from '@/application/Parser/Script/Compiler/Expressions/Parser/CompositeExpressionParser';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'mocha';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ExpressionRegexBuilder } from '@/application/Parser/Script/Compiler/Expressions/Parser/Regex/ExpressionRegexBuilder';
|
||||
|
||||
describe('ExpressionRegexBuilder', () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ExpressionEvaluator } from '@/application/Parser/Script/Compiler/Expressions/Expression/Expression';
|
||||
import { IPrimitiveExpression, RegexParser } from '@/application/Parser/Script/Compiler/Expressions/Parser/Regex/RegexParser';
|
||||
import { ExpressionPosition } from '@/application/Parser/Script/Compiler/Expressions/Expression/ExpressionPosition';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'mocha';
|
||||
import { describe } from 'vitest';
|
||||
import { EscapeDoubleQuotes } from '@/application/Parser/Script/Compiler/Expressions/Pipes/PipeDefinitions/EscapeDoubleQuotes';
|
||||
import { AbsentStringTestCases } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
import { runPipeTests } from './PipeTestRunner';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'mocha';
|
||||
import { describe } from 'vitest';
|
||||
import { InlinePowerShell } from '@/application/Parser/Script/Compiler/Expressions/Pipes/PipeDefinitions/InlinePowerShell';
|
||||
import { IPipeTestCase, runPipeTests } from './PipeTestRunner';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { it, expect } from 'vitest';
|
||||
import { IPipe } from '@/application/Parser/Script/Compiler/Expressions/Pipes/IPipe';
|
||||
|
||||
export interface IPipeTestCase {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { PipeFactory } from '@/application/Parser/Script/Compiler/Expressions/Pipes/PipeFactory';
|
||||
import { PipeStub } from '@tests/unit/shared/Stubs/PipeStub';
|
||||
import { AbsentStringTestCases, itEachAbsentObjectValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { PipelineCompiler } from '@/application/Parser/Script/Compiler/Expressions/Pipes/PipelineCompiler';
|
||||
import { IPipelineCompiler } from '@/application/Parser/Script/Compiler/Expressions/Pipes/IPipelineCompiler';
|
||||
import { IPipeFactory } from '@/application/Parser/Script/Compiler/Expressions/Pipes/PipeFactory';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'mocha';
|
||||
import { describe } from 'vitest';
|
||||
import { ParameterSubstitutionParser } from '@/application/Parser/Script/Compiler/Expressions/SyntaxParsers/ParameterSubstitutionParser';
|
||||
import { ExpressionPosition } from '@/application/Parser/Script/Compiler/Expressions/Expression/ExpressionPosition';
|
||||
import { SyntaxParserTestsRunner } from './SyntaxParserTestsRunner';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { it, expect } from 'vitest';
|
||||
import { ExpressionPosition } from '@/application/Parser/Script/Compiler/Expressions/Expression/ExpressionPosition';
|
||||
import { IExpressionParser } from '@/application/Parser/Script/Compiler/Expressions/Parser/IExpressionParser';
|
||||
import { FunctionCallArgumentCollectionStub } from '@tests/unit/shared/Stubs/FunctionCallArgumentCollectionStub';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'mocha';
|
||||
import { describe } from 'vitest';
|
||||
import { ExpressionPosition } from '@/application/Parser/Script/Compiler/Expressions/Expression/ExpressionPosition';
|
||||
import { WithParser } from '@/application/Parser/Script/Compiler/Expressions/SyntaxParsers/WithParser';
|
||||
import { AbsentStringTestCases } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, expect } from 'vitest';
|
||||
import { FunctionCallArgument } from '@/application/Parser/Script/Compiler/Function/Call/Argument/FunctionCallArgument';
|
||||
import { itEachAbsentStringValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
import { testParameterName } from '../../../ParameterNameTestRunner';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { FunctionCallArgumentCollection } from '@/application/Parser/Script/Compiler/Function/Call/Argument/FunctionCallArgumentCollection';
|
||||
import { FunctionCallArgumentStub } from '@tests/unit/shared/Stubs/FunctionCallArgumentStub';
|
||||
import { itEachAbsentObjectValue, itEachAbsentStringValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import type { FunctionCallParametersData } from '@/application/collections/';
|
||||
import { FunctionCallCompiler } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/FunctionCallCompiler';
|
||||
import { ISharedFunctionCollection } from '@/application/Parser/Script/Compiler/Function/ISharedFunctionCollection';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { FunctionCall } from '@/application/Parser/Script/Compiler/Function/Call/FunctionCall';
|
||||
import { IReadOnlyFunctionCallArgumentCollection } from '@/application/Parser/Script/Compiler/Function/Call/Argument/IFunctionCallArgumentCollection';
|
||||
import { FunctionCallArgumentCollectionStub } from '@tests/unit/shared/Stubs/FunctionCallArgumentCollectionStub';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { parseFunctionCalls } from '@/application/Parser/Script/Compiler/Function/Call/FunctionCallParser';
|
||||
import { FunctionCallDataStub } from '@tests/unit/shared/Stubs/FunctionCallDataStub';
|
||||
import { itEachAbsentObjectValue, itEachAbsentStringValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { FunctionParameter } from '@/application/Parser/Script/Compiler/Function/Parameter/FunctionParameter';
|
||||
import { testParameterName } from '../../ParameterNameTestRunner';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { FunctionParameterCollection } from '@/application/Parser/Script/Compiler/Function/Parameter/FunctionParameterCollection';
|
||||
import { FunctionParameterStub } from '@tests/unit/shared/Stubs/FunctionParameterStub';
|
||||
import { itEachAbsentObjectValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { IReadOnlyFunctionParameterCollection } from '@/application/Parser/Script/Compiler/Function/Parameter/IFunctionParameterCollection';
|
||||
import { FunctionParameterCollectionStub } from '@tests/unit/shared/Stubs/FunctionParameterCollectionStub';
|
||||
import { createCallerFunction, createFunctionWithInlineCode } from '@/application/Parser/Script/Compiler/Function/SharedFunction';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { SharedFunctionCollection } from '@/application/Parser/Script/Compiler/Function/SharedFunctionCollection';
|
||||
import { SharedFunctionStub } from '@tests/unit/shared/Stubs/SharedFunctionStub';
|
||||
import { FunctionBodyType } from '@/application/Parser/Script/Compiler/Function/ISharedFunction';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import type { FunctionData } from '@/application/collections/';
|
||||
import { ISharedFunction } from '@/application/Parser/Script/Compiler/Function/ISharedFunction';
|
||||
import { SharedFunctionsParser } from '@/application/Parser/Script/Compiler/Function/SharedFunctionsParser';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { AbsentStringTestCases } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
export function testParameterName(action: (parameterName: string) => string) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import type { FunctionData } from '@/application/collections/';
|
||||
import { ScriptCode } from '@/domain/ScriptCode';
|
||||
import { ScriptCompiler } from '@/application/Parser/Script/Compiler/ScriptCompiler';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import type { ScriptData } from '@/application/collections/';
|
||||
import { parseScript, ScriptFactoryType } from '@/application/Parser/Script/ScriptParser';
|
||||
import { parseDocs } from '@/application/Parser/DocumentationParser';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { CodeValidator } from '@/application/Parser/Script/Validation/CodeValidator';
|
||||
import { CodeValidationRuleStub } from '@tests/unit/shared/Stubs/CodeValidationRuleStub';
|
||||
import { itEachAbsentCollectionValue, itEachAbsentStringValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { it, expect } from 'vitest';
|
||||
import { ICodeValidationRule, IInvalidCodeLine } from '@/application/Parser/Script/Validation/ICodeValidationRule';
|
||||
import { ICodeLine } from '@/application/Parser/Script/Validation/ICodeLine';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, expect } from 'vitest';
|
||||
import { itEachAbsentObjectValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
import { NoDuplicatedLines } from '@/application/Parser/Script/Validation/Rules/NoDuplicatedLines';
|
||||
import { LanguageSyntaxStub } from '@tests/unit/shared/Stubs/LanguageSyntaxStub';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { describe } from 'vitest';
|
||||
import { NoEmptyLines } from '@/application/Parser/Script/Validation/Rules/NoEmptyLines';
|
||||
import { testCodeValidationRule } from './CodeValidationRuleTestRunner';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ShellScriptSyntax } from '@/application/Parser/Script/Validation/Syntax/ShellScriptSyntax';
|
||||
import { ILanguageSyntax } from '@/application/Parser/Script/Validation/Syntax/ILanguageSyntax';
|
||||
import { BatchFileSyntax } from '@/application/Parser/Script/Validation/Syntax/BatchFileSyntax';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'mocha';
|
||||
import { describe } from 'vitest';
|
||||
import { SyntaxFactory } from '@/application/Parser/Script/Validation/Syntax/SyntaxFactory';
|
||||
import { ScriptingLanguage } from '@/domain/ScriptingLanguage';
|
||||
import { ShellScriptSyntax } from '@/application/Parser/Script/Validation/Syntax/ShellScriptSyntax';
|
||||
@@ -8,7 +8,7 @@ import { BatchFileSyntax } from '@/application/Parser/Script/Validation/Syntax/B
|
||||
describe('SyntaxFactory', () => {
|
||||
const sut = new SyntaxFactory();
|
||||
const runner = new ScriptingLanguageFactoryTestRunner()
|
||||
.expect(ScriptingLanguage.shellscript, ShellScriptSyntax)
|
||||
.expect(ScriptingLanguage.batchfile, BatchFileSyntax);
|
||||
.expectInstance(ScriptingLanguage.shellscript, ShellScriptSyntax)
|
||||
.expectInstance(ScriptingLanguage.batchfile, BatchFileSyntax);
|
||||
runner.testCreateMethod(sut);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { CodeSubstituter } from '@/application/Parser/ScriptingDefinition/CodeSubstituter';
|
||||
import { IExpressionsCompiler } from '@/application/Parser/Script/Compiler/Expressions/IExpressionsCompiler';
|
||||
import { ProjectInformationStub } from '@tests/unit/shared/Stubs/ProjectInformationStub';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ScriptingLanguage } from '@/domain/ScriptingLanguage';
|
||||
import { ScriptingDefinitionParser } from '@/application/Parser/ScriptingDefinition/ScriptingDefinitionParser';
|
||||
import { IEnumParser } from '@/application/Common/Enum';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'mocha';
|
||||
import { resolve, join, basename } from 'path';
|
||||
import { readdirSync, readFileSync } from 'fs';
|
||||
import { expect } from 'chai';
|
||||
import { resolve, join, basename } from 'path';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
/*
|
||||
A common mistake when working with yaml files to forget mentioning that a value should
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { Application } from '@/domain/Application';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { CategoryCollectionStub } from '@tests/unit/shared/Stubs/CategoryCollectionStub';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { Category } from '@/domain/Category';
|
||||
import { CategoryStub } from '@tests/unit/shared/Stubs/CategoryStub';
|
||||
import { ScriptStub } from '@tests/unit/shared/Stubs/ScriptStub';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ICategory } from '@/domain/ICategory';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { IScriptingDefinition } from '@/domain/IScriptingDefinition';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ProjectInformation } from '@/domain/ProjectInformation';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { EnumRangeTestRunner } from '@tests/unit/application/Common/EnumRangeTestRunner';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { getEnumValues } from '@/application/Common/Enum';
|
||||
import { Script } from '@/domain/Script';
|
||||
import { RecommendationLevel } from '@/domain/RecommendationLevel';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ScriptCode } from '@/domain/ScriptCode';
|
||||
import { AbsentStringTestCases } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ScriptingDefinition } from '@/domain/ScriptingDefinition';
|
||||
import { ScriptingLanguage } from '@/domain/ScriptingLanguage';
|
||||
import { getEnumValues } from '@/application/Common/Enum';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { Version } from '@/domain/Version';
|
||||
|
||||
describe('Version', () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { EnvironmentStub } from '@tests/unit/shared/Stubs/EnvironmentStub';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { CodeRunner } from '@/infrastructure/CodeRunner';
|
||||
@@ -193,7 +192,7 @@ function getNodeJsMocks() {
|
||||
}
|
||||
|
||||
function mockOs(commandHistory: NodeJsCommand[]) {
|
||||
let tmpDir: string;
|
||||
let tmpDir = '/stub-temp-dir/';
|
||||
return {
|
||||
setupTmpdir: (value: string): void => {
|
||||
tmpDir = value;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import {
|
||||
describe, it, expect, beforeEach,
|
||||
} from 'vitest';
|
||||
import { EventHandler, IEventSource, IEventSubscription } from '@/infrastructure/Events/IEventSource';
|
||||
import { EventSource } from '@/infrastructure/Events/EventSource';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { EventSubscriptionCollection } from '@/infrastructure/Events/EventSubscriptionCollection';
|
||||
import { IEventSubscription } from '@/infrastructure/Events/IEventSource';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { NumericEntityStub } from '@tests/unit/shared/Stubs/NumericEntityStub';
|
||||
import { InMemoryRepository } from '@/infrastructure/Repository/InMemoryRepository';
|
||||
import { itEachAbsentObjectValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import {
|
||||
describe, it, expect, beforeEach,
|
||||
} from 'vitest';
|
||||
import { AsyncLazy } from '@/infrastructure/Threading/AsyncLazy';
|
||||
import { sleep } from '@/infrastructure/Threading/AsyncSleep';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { sleep, SchedulerType, SchedulerCallbackType } from '@/infrastructure/Threading/AsyncSleep';
|
||||
|
||||
describe('AsyncSleep', () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { IInstructionsBuilderData, InstructionsBuilder, InstructionStepBuilderType } from '@/presentation/components/Code/CodeButtons/Instructions/Data/InstructionsBuilder';
|
||||
import { itEachAbsentObjectValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'mocha';
|
||||
import { describe } from 'vitest';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { MacOsInstructionsBuilder } from '@/presentation/components/Code/CodeButtons/Instructions/Data/MacOsInstructionsBuilder';
|
||||
import { runOsSpecificInstructionBuilderTests } from './OsSpecificInstructionBuilderTestRunner';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { expect } from 'chai';
|
||||
import { it, expect } from 'vitest';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { InstructionsBuilder } from '@/presentation/components/Code/CodeButtons/Instructions/Data/InstructionsBuilder';
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user