rename Application to CategoryCollection #40

This commit is contained in:
undergroundwires
2021-01-02 03:13:01 +01:00
parent 7cc161c828
commit 6fe858d86a
42 changed files with 350 additions and 311 deletions

View File

@@ -4,7 +4,7 @@ import { ScriptStub } from '../../../../../../stubs/ScriptStub';
import { CategoryReverter } from '@/presentation/Scripts/ScriptsTree/SelectableTree/Node/Reverter/CategoryReverter';
import { getCategoryNodeId } from '@/presentation/Scripts/ScriptsTree/ScriptNodeParser';
import { CategoryStub } from '../../../../../../stubs/CategoryStub';
import { ApplicationStub } from '../../../../../../stubs/ApplicationStub';
import { CategoryCollectionStub } from '../../../../../../stubs/CategoryCollectionStub';
import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript';
import { UserSelection } from '@/application/Context/State/Selection/UserSelection';
@@ -17,8 +17,8 @@ describe('CategoryReverter', () => {
];
const category = new CategoryStub(1).withScripts(...scripts);
const nodeId = getCategoryNodeId(category);
const app = new ApplicationStub().withAction(category);
const sut = new CategoryReverter(nodeId, app);
const collection = new CategoryCollectionStub().withAction(category);
const sut = new CategoryReverter(nodeId, collection);
const testCases = [
{
name: 'false when subscripts are not reverted',
@@ -52,7 +52,7 @@ describe('CategoryReverter', () => {
new ScriptStub('revertable2').withRevertCode('REM revert me 2'),
];
const category = new CategoryStub(1).withScripts(...scripts);
const app = new ApplicationStub().withAction(category);
const collection = new CategoryCollectionStub().withAction(category);
const testCases = [
{
name: 'selects with revert state when not selected',
@@ -88,8 +88,8 @@ describe('CategoryReverter', () => {
const nodeId = getCategoryNodeId(category);
for (const testCase of testCases) {
it(testCase.name, () => {
const selection = new UserSelection(app, testCase.selection);
const sut = new CategoryReverter(nodeId, app);
const selection = new UserSelection(collection, testCase.selection);
const sut = new CategoryReverter(nodeId, collection);
// act
sut.selectWithRevertState(testCase.revert, selection);
// assert

View File

@@ -4,7 +4,7 @@ import { INode, NodeType } from '@/presentation/Scripts/ScriptsTree/SelectableTr
import { getReverter } from '@/presentation/Scripts/ScriptsTree/SelectableTree/Node/Reverter/ReverterFactory';
import { ScriptReverter } from '@/presentation/Scripts/ScriptsTree/SelectableTree/Node/Reverter/ScriptReverter';
import { CategoryReverter } from '@/presentation/Scripts/ScriptsTree/SelectableTree/Node/Reverter/CategoryReverter';
import { ApplicationStub } from '../../../../../../stubs/ApplicationStub';
import { CategoryCollectionStub } from '../../../../../../stubs/CategoryCollectionStub';
import { CategoryStub } from '../../../../../../stubs/CategoryStub';
import { getScriptNodeId, getCategoryNodeId } from '@/presentation/Scripts/ScriptsTree/ScriptNodeParser';
import { ScriptStub } from '../../../../../../stubs/ScriptStub';
@@ -15,9 +15,10 @@ describe('ReverterFactory', () => {
// arrange
const category = new CategoryStub(0).withScriptIds('55');
const node = getNodeStub(getCategoryNodeId(category), NodeType.Category);
const app = new ApplicationStub().withAction(category);
const collection = new CategoryCollectionStub()
.withAction(category);
// act
const result = getReverter(node, app);
const result = getReverter(node, collection);
// assert
expect(result instanceof CategoryReverter).to.equal(true);
});
@@ -25,9 +26,10 @@ describe('ReverterFactory', () => {
// arrange
const script = new ScriptStub('test');
const node = getNodeStub(getScriptNodeId(script), NodeType.Script);
const app = new ApplicationStub().withAction(new CategoryStub(0).withScript(script));
const collection = new CategoryCollectionStub()
.withAction(new CategoryStub(0).withScript(script));
// act
const result = getReverter(node, app);
const result = getReverter(node, collection);
// assert
expect(result instanceof ScriptReverter).to.equal(true);
});

View File

@@ -1,13 +1,13 @@
import 'mocha';
import { expect } from 'chai';
import { ScriptReverter } from '@/presentation/Scripts/ScriptsTree/SelectableTree/Node/Reverter/ScriptReverter';
import { SelectedScriptStub } from '../../../../../../stubs/SelectedScriptStub';
import { getScriptNodeId } from '@/presentation/Scripts/ScriptsTree/ScriptNodeParser';
import { ScriptStub } from '../../../../../../stubs/ScriptStub';
import { UserSelection } from '@/application/Context/State/Selection/UserSelection';
import { SelectedScript } from '@/application/Context/State/Selection/SelectedScript';
import { ApplicationStub } from '../../../../../../stubs/ApplicationStub';
import { CategoryCollectionStub } from '../../../../../../stubs/CategoryCollectionStub';
import { CategoryStub } from '../../../../../../stubs/CategoryStub';
import { ScriptStub } from '../../../../../../stubs/ScriptStub';
import { SelectedScriptStub } from '../../../../../../stubs/SelectedScriptStub';
describe('ScriptReverter', () => {
describe('getState', () => {
@@ -45,7 +45,8 @@ describe('ScriptReverter', () => {
describe('selectWithRevertState', () => {
// arrange
const script = new ScriptStub('id');
const app = new ApplicationStub().withAction(new CategoryStub(5).withScript(script));
const collection = new CategoryCollectionStub()
.withAction(new CategoryStub(5).withScript(script));
const testCases = [
{
name: 'selects with revert state when not selected',
@@ -75,7 +76,7 @@ describe('ScriptReverter', () => {
const nodeId = getScriptNodeId(script);
for (const testCase of testCases) {
it(testCase.name, () => {
const selection = new UserSelection(app, testCase.selection);
const selection = new UserSelection(collection, testCase.selection);
const sut = new ScriptReverter(nodeId);
// act
sut.selectWithRevertState(testCase.revert, selection);