The project's slagon has been updated back to "Privacy is sexy" from "Now you have the choice" for enhanced brand clarity and memorability. This change also reflects the community's preference and aligns with the project's established identity. This commit also refactors naming and structure of project information (metadata) struct to enhance clarity and maintainability in relation to changing the slogan. Key changes include: - Update UI components to display the revised slogan. - Remove period from project slogan in code area for consistency with a explanatory comment for future maintainability. - Refactor header container and class names for clarity. - Standardize project metadata usage in `TheCodeArea.vue` to ensure consistency. - Improve code clarity by renaming `IProjectInformation` to `ProjectDetails` and `ProjectInformation` to `GitHubProjectDetails`. - Organize `ProjectDetails` under a dedicated `Project` directory within the domain layer for better structure. These changes are expected to improve the project's appeal and streamline future maintenance and development efforts.
120 lines
5.5 KiB
TypeScript
120 lines
5.5 KiB
TypeScript
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 { OperatingSystem } from '@/domain/OperatingSystem';
|
|
import { RecommendationLevel } from '@/domain/RecommendationLevel';
|
|
import { ScriptingDefinitionParser } from '@/application/Parser/ScriptingDefinition/ScriptingDefinitionParser';
|
|
import { EnumParserStub } from '@tests/unit/shared/Stubs/EnumParserStub';
|
|
import { ProjectDetailsStub } from '@tests/unit/shared/Stubs/ProjectDetailsStub';
|
|
import { getCategoryStub, CollectionDataStub } from '@tests/unit/shared/Stubs/CollectionDataStub';
|
|
import { CategoryCollectionParseContextStub } from '@tests/unit/shared/Stubs/CategoryCollectionParseContextStub';
|
|
import { CategoryDataStub } from '@tests/unit/shared/Stubs/CategoryDataStub';
|
|
import { createScriptDataWithCall, createScriptDataWithCode } from '@tests/unit/shared/Stubs/ScriptDataStub';
|
|
import { createFunctionDataWithCode } from '@tests/unit/shared/Stubs/FunctionDataStub';
|
|
import { FunctionCallDataStub } from '@tests/unit/shared/Stubs/FunctionCallDataStub';
|
|
import { itEachAbsentCollectionValue } from '@tests/unit/shared/TestCases/AbsentTests';
|
|
import type { CategoryData } from '@/application/collections/';
|
|
|
|
describe('CategoryCollectionParser', () => {
|
|
describe('parseCategoryCollection', () => {
|
|
describe('actions', () => {
|
|
describe('throws with absent actions', () => {
|
|
itEachAbsentCollectionValue<CategoryData>((absentValue) => {
|
|
// arrange
|
|
const expectedError = 'content does not define any action';
|
|
const collection = new CollectionDataStub()
|
|
.withActions(absentValue);
|
|
const projectDetails = new ProjectDetailsStub();
|
|
// act
|
|
const act = () => parseCategoryCollection(collection, projectDetails);
|
|
// assert
|
|
expect(act).to.throw(expectedError);
|
|
}, { excludeUndefined: true, excludeNull: true });
|
|
});
|
|
it('parses actions', () => {
|
|
// arrange
|
|
const actions = [getCategoryStub('test1'), getCategoryStub('test2')];
|
|
const context = new CategoryCollectionParseContextStub();
|
|
const expected = [parseCategory(actions[0], context), parseCategory(actions[1], context)];
|
|
const collection = new CollectionDataStub()
|
|
.withActions(actions);
|
|
const projectDetails = new ProjectDetailsStub();
|
|
// act
|
|
const actual = parseCategoryCollection(collection, projectDetails).actions;
|
|
// assert
|
|
expect(excludingId(actual)).to.be.deep.equal(excludingId(expected));
|
|
function excludingId<TId>(array: ReadonlyArray<IEntity<TId>>) {
|
|
return array.map((obj) => {
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
const { id: omitted, ...rest } = obj;
|
|
return rest;
|
|
});
|
|
}
|
|
});
|
|
});
|
|
describe('scripting definition', () => {
|
|
it('parses scripting definition as expected', () => {
|
|
// arrange
|
|
const collection = new CollectionDataStub();
|
|
const projectDetails = new ProjectDetailsStub();
|
|
const expected = new ScriptingDefinitionParser()
|
|
.parse(collection.scripting, projectDetails);
|
|
// act
|
|
const actual = parseCategoryCollection(collection, projectDetails).scripting;
|
|
// assert
|
|
expect(expected).to.deep.equal(actual);
|
|
});
|
|
});
|
|
describe('os', () => {
|
|
it('parses as expected', () => {
|
|
// arrange
|
|
const expectedOs = OperatingSystem.macOS;
|
|
const osText = 'macos';
|
|
const expectedName = 'os';
|
|
const collection = new CollectionDataStub()
|
|
.withOs(osText);
|
|
const parserMock = new EnumParserStub<OperatingSystem>()
|
|
.setup(expectedName, osText, expectedOs);
|
|
const projectDetails = new ProjectDetailsStub();
|
|
// act
|
|
const actual = parseCategoryCollection(collection, projectDetails, parserMock);
|
|
// assert
|
|
expect(actual.os).to.equal(expectedOs);
|
|
});
|
|
});
|
|
describe('functions', () => {
|
|
it('compiles script call with given function', () => {
|
|
// arrange
|
|
const expectedCode = 'code-from-the-function';
|
|
const functionName = 'function-name';
|
|
const scriptName = 'script-name';
|
|
const script = createScriptDataWithCall()
|
|
.withCall(new FunctionCallDataStub().withName(functionName).withParameters({}))
|
|
.withName(scriptName);
|
|
const func = createFunctionDataWithCode()
|
|
.withParametersObject([])
|
|
.withName(functionName)
|
|
.withCode(expectedCode);
|
|
const category = new CategoryDataStub()
|
|
.withChildren([script,
|
|
createScriptDataWithCode().withName('2')
|
|
.withRecommendationLevel(RecommendationLevel.Standard),
|
|
createScriptDataWithCode()
|
|
.withName('3').withRecommendationLevel(RecommendationLevel.Strict),
|
|
]);
|
|
const collection = new CollectionDataStub()
|
|
.withActions([category])
|
|
.withFunctions([func]);
|
|
const projectDetails = new ProjectDetailsStub();
|
|
// act
|
|
const actual = parseCategoryCollection(collection, projectDetails);
|
|
// assert
|
|
const actualScript = actual.getScript(scriptName);
|
|
const actualCode = actualScript.code.execute;
|
|
expect(actualCode).to.equal(expectedCode);
|
|
});
|
|
});
|
|
});
|
|
});
|