Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/3250/ngrx #3271

Merged
merged 71 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
c0e2b27
refactor: WIP no compile error but not working yet
shaman-apprentice Mar 30, 2023
e697464
refactor: WIP some catches
shaman-apprentice Mar 31, 2023
1918b54
refactor: WIP strong type reducers with none basic types
shaman-apprentice Mar 31, 2023
70156a6
refactor: WIP correct store init
shaman-apprentice Mar 31, 2023
4795285
refactor: WIP basically add setState
shaman-apprentice Mar 31, 2023
7846de4
refactor: WIP add null check
shaman-apprentice Mar 31, 2023
90692ae
refactor: WIP fix inplace mutation of state
shaman-apprentice Mar 31, 2023
4554f17
refactor: WIP fix initial color reset
shaman-apprentice Mar 31, 2023
2053065
refactor: WIP enable reset button again
shaman-apprentice Mar 31, 2023
42334c8
refactor: WIP fix initial endless loop
shaman-apprentice Mar 31, 2023
942edc9
refactor: WIP enable reset of color range again
shaman-apprentice Mar 31, 2023
cedc9eb
refactor: WIP fix set hovered node id
shaman-apprentice Mar 31, 2023
264cbc8
refactor: improve filtering
shaman-apprentice Apr 2, 2023
6f0d422
refactor: scroll over changes and small adjustments
shaman-apprentice Apr 2, 2023
5bb4bf5
refactor: inplace vars
shaman-apprentice Apr 2, 2023
681c858
refactor: little perf improvement
shaman-apprentice Apr 2, 2023
b1e78a1
fix: correct color Mode default value
shaman-apprentice Apr 7, 2023
db8276e
fix: add missing import
shaman-apprentice Apr 11, 2023
9be4774
fix: fix selectors firing to often
shaman-apprentice Apr 11, 2023
fb283ea
refactor: add type
shaman-apprentice Apr 11, 2023
e4100cb
Merge remote-tracking branch 'origin/main' into refactor/3250/ngrx
shaman-apprentice Apr 11, 2023
7912356
refactor: rename payload -> action
shaman-apprentice Apr 11, 2023
1c268ba
fix: re-enable loading spinners again
shaman-apprentice Apr 11, 2023
604963e
refactor: rename obsolete reduxHelper
shaman-apprentice Apr 11, 2023
3e403fb
refactor: inline return
shaman-apprentice Apr 11, 2023
885a8ac
refactor: remove not needed cast
shaman-apprentice Apr 11, 2023
efdeb3c
fix: prevent inplace mutation of store
shaman-apprentice Apr 11, 2023
c7cf52d
refactor: State -> CcState
shaman-apprentice Apr 11, 2023
477d7e1
refactor: StateService -> State
shaman-apprentice Apr 11, 2023
e0e3eb5
test: adjust store appSettings tests
shaman-apprentice Apr 11, 2023
62d7d5c
test: adjust some more store tests
shaman-apprentice Apr 11, 2023
0f64a90
test: adjust some more store tests
shaman-apprentice Apr 12, 2023
10ceecc
test: migrate first effect
shaman-apprentice Apr 12, 2023
454f78b
fix: prevent mutating state
shaman-apprentice Apr 12, 2023
e1644bd
test: adjust another test
shaman-apprentice Apr 12, 2023
fbc6584
test: adjust some more tests
shaman-apprentice Apr 12, 2023
993af5b
test: adjust some more tests
shaman-apprentice Apr 12, 2023
f60a011
test: adjust some more tests
shaman-apprentice Apr 13, 2023
90bb14a
fix: changing layout algorithm
shaman-apprentice Apr 13, 2023
90b6af4
fix: changing sharpness mode
shaman-apprentice Apr 13, 2023
edc67b7
fix: show edges again
shaman-apprentice Apr 13, 2023
6a88e8a
test: adjust some more tests
shaman-apprentice Apr 13, 2023
16c2158
fix: prevent forbitten inplace mutation
shaman-apprentice Apr 13, 2023
fe78436
test: adjust some more tests
shaman-apprentice Apr 13, 2023
72d71eb
test: adjust some more tests
shaman-apprentice Apr 13, 2023
5e032ad
test: adjust some more tests
shaman-apprentice Apr 16, 2023
04337a2
test: adjust some more tests
shaman-apprentice Apr 17, 2023
9295318
refactor: remove doubled test
shaman-apprentice Apr 17, 2023
eaef962
refactor: be more specific than any as derived typed
shaman-apprentice Apr 17, 2023
e80dcab
test: adjust some more tests
shaman-apprentice Apr 17, 2023
99b6cad
Merge remote-tracking branch 'origin/main' into refactor/3250/ngrx
shaman-apprentice Apr 17, 2023
3b8f03f
test: adjust another test
shaman-apprentice Apr 18, 2023
8143ed8
test: adjust some more tests
shaman-apprentice Apr 20, 2023
8ea7af8
test: remove manipulation of test data / dependencies between tests a…
shaman-apprentice Apr 20, 2023
6f7f8c3
test: adjust some more tests
shaman-apprentice Apr 20, 2023
fe1c2d4
adjust some more tests
shaman-apprentice Apr 20, 2023
4c33a63
test: adjust some more tests
shaman-apprentice Apr 21, 2023
ab2e4ba
test: remove data manipulation
shaman-apprentice Apr 21, 2023
fdeb2fd
refactor(performance): don't execute side effects multiple times
shaman-apprentice Apr 21, 2023
74d1a59
refactor: rename property
shaman-apprentice Apr 22, 2023
5a33bae
test: adjust test to previously removal of manipulation of test data
shaman-apprentice Apr 22, 2023
8f1e0ae
test: adjust some more tests
shaman-apprentice Apr 22, 2023
4fcbea0
test: remove not useful test
shaman-apprentice Apr 22, 2023
e6aee4c
refactor: be more explicit about loading indicators
shaman-apprentice Apr 22, 2023
3498614
refactor: remove dev tools
shaman-apprentice Apr 22, 2023
874a36a
revert: be more explicit about loading indicators
shaman-apprentice Apr 23, 2023
b84fcec
docs: add changelog
shaman-apprentice Apr 23, 2023
d5423b9
fix: reset colors when applying scenario without colors
shaman-apprentice Apr 24, 2023
0cb2a02
Merge remote-tracking branch 'origin/main' into refactor/3250/ngrx
shaman-apprentice Apr 27, 2023
d9cb7a6
fix: restore old behavior to reset state when dispatching undefined
shaman-apprentice Apr 27, 2023
511f50e
Merge remote-tracking branch 'origin/main' into refactor/3250/ngrx
shaman-apprentice Apr 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/)
### Fixed 🐞

- Fix suspicious metrics and risk profile docs not loading [#3272](https://github.com/MaibornWolff/codecharta/pull/3272)
- Show again delta of a building which have nothing in common in red or green [#3271](https://github.com/MaibornWolff/codecharta/pull/3271)

### Chore 👨‍💻 👩‍💻

- Replace custom Redux adapter through real NgRx [#3271](https://github.com/MaibornWolff/codecharta/pull/3271)

## [1.115.1] - 2023-04-06

Expand Down
15 changes: 10 additions & 5 deletions visualization/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,35 @@ import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"
import { HttpClientModule } from "@angular/common/http"
import { FormsModule, ReactiveFormsModule } from "@angular/forms"
import { MaterialModule } from "./material/material.module"
import { EffectsModule } from "./codeCharta/state/angular-redux/effects/effects.module"
import { EffectsModule } from "@ngrx/effects"
import { UnfocusNodesEffect } from "./codeCharta/state/effects/unfocusNodes/unfocusNodes.effect"
import { AddBlacklistItemsIfNotResultsInEmptyMapEffect } from "./codeCharta/state/effects/addBlacklistItemsIfNotResultsInEmptyMap/addBlacklistItemsIfNotResultsInEmptyMap.effect"
import { dialogs } from "./codeCharta/ui/dialogs/dialogs"
import { OpenNodeContextMenuEffect } from "./codeCharta/state/effects/nodeContextMenu/openNodeContextMenu.effect"
import { BlacklistSearchPatternEffect } from "./codeCharta/ui/searchPanel/searchBar/blacklistSearchPattern.effect"
import { ResetColorRangeEffect } from "./codeCharta/state/store/dynamicSettings/colorRange/resetColorRange.effect"
import { ResetChosenMetricsEffect } from "./codeCharta/state/effects/resetChosenMetrics/resetChosenMetrics.effect"
import { UpdateEdgePreviewsEffect } from "./codeCharta/state/effects/updateEdgePreviews/updateEdgePreviews.effect"
import { ChangelogDialogModule } from "./codeCharta/ui/dialogs/changelogDialog/changelogDialog.module"
import { VersionService } from "./codeCharta/services/version/version.service"
import { RenderCodeMapEffect } from "./codeCharta/state/effects/renderCodeMapEffect/renderCodeMap.effect"
import { AutoFitCodeMapEffect } from "./codeCharta/state/effects/autoFitCodeMapChange/autoFitCodeMap.effect"
import { CodeChartaModule } from "./codeCharta/codeCharta.module"
import { UpdateVisibleTopLabelsEffect } from "./codeCharta/state/effects/updateVisibleTopLabels/updateVisibleTopLabels.effect"
import { ResetSelectedEdgeMetricWhenItDoesntExistAnymoreEffect } from "./codeCharta/state/effects/resetSelectedEdgeMetricWhenItDoesntExistAnymore/resetSelectedEdgeMetricWhenItDoesntExistAnymore.effect"
import { LinkColorMetricToHeightMetricEffect } from "./codeCharta/state/effects/linkColorMetricToHeightMetric/linkColorMetricToHeightMetric.effect"
import { UpdateFileSettingsEffect } from "./codeCharta/state/effects/updateFileSettings/updateFileSettings.effect"
import { CodeChartaComponent } from "./codeCharta/codeCharta.component"
import { NodeContextMenuCardModule } from "./codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/nodeContextMenuCard.module"
import { StoreModule } from "@ngrx/store"
import { appReducers, setStateMiddleware } from "./codeCharta/state/store/state.manager"
import { ResetColorRangeEffect } from "./codeCharta/state/store/dynamicSettings/colorRange/resetColorRange.effect"
import { ResetChosenMetricsEffect } from "./codeCharta/state/effects/resetChosenMetrics/resetChosenMetrics.effect"
import { ResetSelectedEdgeMetricWhenItDoesntExistAnymoreEffect } from "./codeCharta/state/effects/resetSelectedEdgeMetricWhenItDoesntExistAnymore/resetSelectedEdgeMetricWhenItDoesntExistAnymore.effect"
import { SetLoadingIndicatorEffect } from "./codeCharta/state/effects/setLoadingIndicator/setLoadingIndicator.effect"

@NgModule({
imports: [
BrowserModule,
HttpClientModule,
StoreModule.forRoot(appReducers, { metaReducers: [setStateMiddleware] }),
EffectsModule.forRoot([
UnfocusNodesEffect,
AddBlacklistItemsIfNotResultsInEmptyMapEffect,
Expand All @@ -42,7 +46,8 @@ import { NodeContextMenuCardModule } from "./codeCharta/state/effects/nodeContex
UpdateVisibleTopLabelsEffect,
LinkColorMetricToHeightMetricEffect,
ResetSelectedEdgeMetricWhenItDoesntExistAnymoreEffect,
UpdateFileSettingsEffect
UpdateFileSettingsEffect,
SetLoadingIndicatorEffect
]),
MaterialModule,
FormsModule,
Expand Down
4 changes: 2 additions & 2 deletions visualization/app/codeCharta/codeCharta.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { TestBed } from "@angular/core/testing"
import { LoadInitialFileService } from "./services/loadInitialFile/loadInitialFile.service"
import { CodeChartaModule } from "./codeCharta.module"
import { CodeChartaComponent } from "./codeCharta.component"
import { Store } from "./state/angular-redux/store"
import { setIsLoadingFile } from "./state/store/appSettings/isLoadingFile/isLoadingFile.actions"
import { Store } from "@ngrx/store"

describe("codeChartaComponent", () => {
beforeEach(() => {
Expand All @@ -20,7 +20,7 @@ describe("codeChartaComponent", () => {
const codeChartaComponent = new CodeChartaComponent(mockedStore, mockedLoadInitialFileService)
await codeChartaComponent.ngOnInit()

expect(mockedStore.dispatch).toHaveBeenCalledWith(setIsLoadingFile(true))
expect(mockedStore.dispatch).toHaveBeenCalledWith(setIsLoadingFile({ value: true }))
expect(mockedLoadInitialFileService.loadFileOrSample).toHaveBeenCalled()
})

Expand Down
4 changes: 2 additions & 2 deletions visualization/app/codeCharta/codeCharta.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { setIsLoadingFile } from "./state/store/appSettings/isLoadingFile/isLoad
import packageJson from "../../package.json"
import { LoadInitialFileService } from "./services/loadInitialFile/loadInitialFile.service"
import { Component, OnInit, ViewEncapsulation } from "@angular/core"
import { Store } from "./state/angular-redux/store"
import { Store } from "@ngrx/store"

@Component({
selector: "cc-code-charta",
Expand All @@ -21,7 +21,7 @@ export class CodeChartaComponent implements OnInit {
}

async ngOnInit(): Promise<void> {
this.store.dispatch(setIsLoadingFile(true))
this.store.dispatch(setIsLoadingFile({ value: true }))
await this.loadInitialFileService.loadFileOrSample()
}
}
36 changes: 14 additions & 22 deletions visualization/app/codeCharta/codeCharta.model.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { Vector3 } from "three"
import { Action } from "redux"
import { ExportCCFile } from "./codeCharta.api.model"
import { FileState } from "./model/files/files"
import { CustomConfig } from "./model/customConfig/customConfig.api.model"
import Rectangle from "./util/algorithm/streetLayout/rectangle"
import { RightClickedNodeData } from "./state/store/appStatus/rightClickedNodeData/rightClickedNodeData.actions"
import { Scaling } from "./state/store/appSettings/scaling/scaling.actions"

export type Scaling = {
x: number
y: number
z: number
}

export interface NameDataPair {
fileName: string
Expand Down Expand Up @@ -85,7 +88,7 @@ export enum SortingOption {
NUMBER_OF_FILES = "Number of Files"
}

export interface colorLabelOptions {
export interface ColorLabelOptions {
positive: boolean
negative: boolean
neutral: boolean
Expand Down Expand Up @@ -155,7 +158,7 @@ export interface AppSettings {
sharpnessMode: SharpnessMode
experimentalFeaturesEnabled: boolean
screenshotToClipboardEnabled: boolean
colorLabels: colorLabelOptions
colorLabels: ColorLabelOptions
isColorMetricLinkedToHeightMetric: boolean
enableFloorLabels: boolean
}
Expand Down Expand Up @@ -347,7 +350,7 @@ export interface Node {
outgoingEdgePoint: Vector3
}

export interface State {
export interface CcState {
fileSettings: FileSettings
dynamicSettings: DynamicSettings
appSettings: AppSettings
Expand Down Expand Up @@ -382,23 +385,12 @@ export function stateObjectReviver(_, valueToRevive) {
return valueToRevive
}

export interface CCAction extends Action {
// TODO: Do not use any here! Make sure all our actions are properly declared.
//
// As a starting point:
//
// RecursivePartial<MetricData & DynamicSettings & FileSettings & AppSettings & FileState> & {
// metricData: MetricData
// dynamicSettings: DynamicSettings
// fileSettings: FileSettings
// appSettings: AppSettings
// files: FileState[]
// }
payload?: any
}

export interface AppStatus {
hoveredNodeId: number | null
selectedBuildingId: number | null
rightClickedNodeData: RightClickedNodeData
rightClickedNodeData: {
nodeId: number
xPositionOfRightClickEvent: number
yPositionOfRightClickEvent: number
} | null
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { TestBed } from "@angular/core/testing"
import { LoadFileService } from "./loadFile.service"
import { TEST_FILE_CONTENT } from "../../util/dataMocks"
import { CCFile, NodeMetricData, NodeType } from "../../codeCharta.model"
import { removeFile, setDeltaReference, setFiles, setStandard } from "../../state/store/files/files.actions"
import { CCFile, CcState, NodeMetricData, NodeType } from "../../codeCharta.model"
import { removeFile, setDeltaReference, setStandard } from "../../state/store/files/files.actions"
import { ExportBlacklistType, ExportCCFile } from "../../codeCharta.api.model"
import { getCCFiles, isPartialState } from "../../model/files/files.helper"
import { CCFileValidationResult, ERROR_MESSAGES } from "../../util/fileValidator"
Expand All @@ -11,11 +11,11 @@ import { clone } from "../../util/clone"
import { klona } from "klona"
import { ErrorDialogComponent } from "../../ui/dialogs/errorDialog/errorDialog.component"
import { loadFilesValidationToErrorDialog } from "../../util/loadFilesValidationToErrorDialog"
import { Store } from "../../state/angular-redux/store"
import { State } from "../../state/angular-redux/state"
import { fileRoot } from "./fileRoot"
import { MatDialog } from "@angular/material/dialog"
import { metricDataSelector } from "../../state/selectors/accumulatedData/metricData/metricData.selector"
import { State, Store, StoreModule } from "@ngrx/store"
import { appReducers, setStateMiddleware } from "../../state/store/state.manager"

const mockedMetricDataSelector = metricDataSelector as unknown as jest.Mock
jest.mock("../../state/selectors/accumulatedData/metricData/metricData.selector", () => ({
Expand All @@ -24,8 +24,8 @@ jest.mock("../../state/selectors/accumulatedData/metricData/metricData.selector"

describe("loadFileService", () => {
let codeChartaService: LoadFileService
let store: Store
let state: State
let store: Store<CcState>
let state: State<CcState>
let dialog: MatDialog
let validFileContent: ExportCCFile
let metricData: NodeMetricData[]
Expand All @@ -41,14 +41,16 @@ describe("loadFileService", () => {
{ name: "mcc", maxValue: 1, minValue: 1 },
{ name: "rloc", maxValue: 2, minValue: 1 }
]
store.dispatch(setFiles([]))
})

afterEach(() => {
codeChartaService.referenceFileSubscription.unsubscribe()
})

function restartSystem() {
TestBed.configureTestingModule({
imports: [StoreModule.forRoot(appReducers, { metaReducers: [setStateMiddleware] })]
})
store = TestBed.inject(Store)
state = TestBed.inject(State)
dialog = { open: jest.fn() } as unknown as MatDialog
Expand Down Expand Up @@ -365,7 +367,7 @@ describe("loadFileService", () => {
{ fileName: "SecondFile", content: validFileContent, fileSize: 42 }
])

store.dispatch(removeFile("FirstFile"))
store.dispatch(removeFile({ fileName: "FirstFile" }))
expect(state.getValue().files).toHaveLength(1)
expect(state.getValue().files[0].file.fileMeta.fileName).toEqual("SecondFile")
})
Expand All @@ -376,12 +378,12 @@ describe("loadFileService", () => {
const updateRootDataSpy = jest.spyOn(fileRoot, "updateRoot")

const newReferenceFile = state.getValue().files[0].file
store.dispatch(setDeltaReference(newReferenceFile))
store.dispatch(setDeltaReference({ file: newReferenceFile }))
expect(updateRootDataSpy).toHaveBeenCalledTimes(1)
expect(updateRootDataSpy).toHaveBeenCalledWith(state.getValue().files[0].file.map.name)

// set reference file to a partial selected file. Therefore reference file becomes undefined
store.dispatch(setStandard([state.getValue().files[0].file]))
store.dispatch(setStandard({ files: [state.getValue().files[0].file] }))
expect(updateRootDataSpy).toHaveBeenCalledTimes(1)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import { clone } from "../../util/clone"
import { CCFileValidationResult } from "../../util/fileValidator"
import { setFiles, setStandardByNames } from "../../state/store/files/files.actions"
import { FileState } from "../../model/files/files"
import { NameDataPair } from "../../codeCharta.model"
import { NameDataPair, CcState } from "../../codeCharta.model"
import { referenceFileSelector } from "../../state/selectors/referenceFile/referenceFile.selector"
import { ErrorDialogComponent } from "../../ui/dialogs/errorDialog/errorDialog.component"
import { loadFilesValidationToErrorDialog } from "../../util/loadFilesValidationToErrorDialog"
import { Store } from "../../state/angular-redux/store"
import { State } from "../../state/angular-redux/state"
import { enrichFileStatesAndRecentFilesWithValidationResults } from "./fileParser"
import { fileRoot } from "./fileRoot"
import { Store, State } from "@ngrx/store"

@Injectable({ providedIn: "root" })
export class LoadFileService implements OnDestroy {
Expand All @@ -29,7 +28,7 @@ export class LoadFileService implements OnDestroy {
)
.subscribe()

constructor(private store: Store, private state: State, private dialog: MatDialog) {}
constructor(private store: Store<CcState>, private state: State<CcState>, private dialog: MatDialog) {}

ngOnDestroy(): void {
this.referenceFileSubscription.unsubscribe()
Expand All @@ -52,11 +51,11 @@ export class LoadFileService implements OnDestroy {
throw new Error("No files could be uploaded")
}

this.store.dispatch(setFiles(fileStates))
this.store.dispatch(setFiles({ value: fileStates }))

const recentFile = recentFiles[0]
const rootName = this.state.getValue().files.find(f => f.file.fileMeta.fileName === recentFile).file.map.name
this.store.dispatch(setStandardByNames(recentFiles))
this.store.dispatch(setStandardByNames({ fileNames: recentFiles }))

fileRoot.updateRoot(rootName)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { TestBed } from "@angular/core/testing"
import { HttpClient } from "@angular/common/http"
import { CCFile, LayoutAlgorithm } from "../../codeCharta.model"
import { State } from "../../state/angular-redux/state"
import { GLOBAL_SETTINGS } from "../../util/dataMocks"
import { GlobalSettingsHelper } from "../../util/globalSettingsHelper"
import { LoadInitialFileService } from "./loadInitialFile.service"
import { Store } from "../../state/angular-redux/store"
import { LoadFileService } from "../loadFile/loadFile.service"
import { ErrorDialogComponent } from "../../ui/dialogs/errorDialog/errorDialog.component"
import sample1 from "../../assets/sample1.cc.json"
import sample2 from "../../assets/sample2.cc.json"
import { FileSelectionState, FileState } from "../../model/files/files"
import { setFiles } from "../../state/store/files/files.actions"
import { MatDialog } from "@angular/material/dialog"
import { State, Store, StoreModule } from "@ngrx/store"
import { appReducers, setStateMiddleware } from "../../state/store/state.manager"

describe("LoadInitialFileService", () => {
let loadInitialFileService: LoadInitialFileService
Expand All @@ -23,9 +23,8 @@ describe("LoadInitialFileService", () => {

mockedDialog = { open: jest.fn() } as unknown as MatDialog
TestBed.configureTestingModule({
imports: [[StoreModule.forRoot(appReducers, { metaReducers: [setStateMiddleware] })]],
providers: [
Store,
State,
{ provide: MatDialog, useValue: mockedDialog },
{ provide: HttpClient, useValue: {} },
{ provide: LoadFileService, useValue: { loadFiles: jest.fn() } }
Expand Down Expand Up @@ -74,36 +73,36 @@ describe("LoadInitialFileService", () => {
it("should set files to standard mode when no 'mode' parameter is given", () => {
const store = TestBed.inject(Store)
const fileState: FileState[] = [{ file: {} as CCFile, selectedAs: FileSelectionState.None }]
store.dispatch(setFiles(fileState))
store.dispatch(setFiles({ value: fileState }))
store.dispatch = jest.fn()
loadInitialFileService["urlUtils"].getParameterByName = () => ""

loadInitialFileService["setRenderStateFromUrl"]()

expect(store.dispatch).toHaveBeenCalledWith({ payload: [{}], type: "SET_STANDARD" })
expect(store.dispatch).toHaveBeenCalledWith({ files: [{}], type: "SET_STANDARD" })
})

it("should set files to multiple mode when any string (except 'Delta') is given", () => {
const store = TestBed.inject(Store)
const fileState: FileState[] = [{ file: {} as CCFile, selectedAs: FileSelectionState.None }]
store.dispatch(setFiles(fileState))
store.dispatch(setFiles({ value: fileState }))
store.dispatch = jest.fn()
loadInitialFileService["urlUtils"].getParameterByName = () => "invalidMode"

loadInitialFileService["setRenderStateFromUrl"]()

expect(store.dispatch).toHaveBeenCalledWith({ payload: [{}], type: "SET_STANDARD" })
expect(store.dispatch).toHaveBeenCalledWith({ files: [{}], type: "SET_STANDARD" })
})

it("should set files to delta mode when 'mode=delta' parameter is given", () => {
const store = TestBed.inject(Store)
const fileState: FileState[] = [{ file: {} as CCFile, selectedAs: FileSelectionState.None }]
store.dispatch(setFiles(fileState))
store.dispatch(setFiles({ value: fileState }))
store.dispatch = jest.fn()
loadInitialFileService["urlUtils"].getParameterByName = () => "Delta"

loadInitialFileService["setRenderStateFromUrl"]()

expect(store.dispatch).toHaveBeenCalledWith({ payload: [{}], type: "SET_STANDARD" })
expect(store.dispatch).toHaveBeenCalledWith({ files: [{}], type: "SET_STANDARD" })
})
})
Loading