-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from SebLeich/features/fixVisualization
Fix visualization
- Loading branch information
Showing
5 changed files
with
149 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
88 changes: 44 additions & 44 deletions
88
projects/storage-manager/src/lib/visualization/services/visualization.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import defaultImportsConstant from '../../../app/default-imports.constant'; | ||
import { VisualizationService } from './visualization.service'; | ||
import { ArrowHelper, GridHelper } from 'three'; | ||
import { IPosition, IPositionedElement, ISpace } from '@/lib/storage-manager/interfaces'; | ||
import { IPositionedElement, ISpace } from '@/lib/storage-manager/interfaces'; | ||
import { infinityReplacement } from '@/app/globals'; | ||
import { SpectatorService, createServiceFactory } from '@ngneat/spectator'; | ||
|
||
describe('SolutionVisualizationService', () => { | ||
const containerLength = 500; | ||
const containerWidth = 1000; | ||
let service: VisualizationService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
providers: [VisualizationService], | ||
imports: [ | ||
...defaultImportsConstant | ||
] | ||
const containerLength = 500; | ||
const containerWidth = 1000; | ||
|
||
let spectator: SpectatorService<VisualizationService>; | ||
|
||
const createService = createServiceFactory({ | ||
imports: [ | ||
...defaultImportsConstant | ||
], | ||
service: VisualizationService, | ||
}); | ||
|
||
beforeEach(() => spectator = createService()); | ||
|
||
it('should be created', () => { | ||
expect(spectator.service).toBeTruthy(); | ||
}); | ||
|
||
it('should create correct grid helper', () => { | ||
const gridHelper = VisualizationService.getContainerBaseGrid(containerWidth, containerLength); | ||
|
||
expect(gridHelper instanceof GridHelper).toBeTruthy(); | ||
expect(gridHelper.position.x).toBe(0); | ||
expect(gridHelper.position.y).toBe(containerWidth / -2); | ||
expect(gridHelper.position.z).toBe(0); | ||
}); | ||
|
||
it('should create unloading arrow', () => { | ||
const unloadingArrow = VisualizationService.getContainerUnloadingArrow(containerLength); | ||
|
||
expect(unloadingArrow instanceof ArrowHelper).toBeTruthy(); | ||
}); | ||
service = TestBed.inject(VisualizationService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
|
||
it('should create correct grid helper', () => { | ||
const gridHelper = VisualizationService.getContainerBaseGrid(containerWidth, containerLength); | ||
|
||
expect(gridHelper instanceof GridHelper).toBeTruthy(); | ||
expect(gridHelper.position.x).toBe(0); | ||
expect(gridHelper.position.y).toBe(containerWidth / -2); | ||
expect(gridHelper.position.z).toBe(0); | ||
}); | ||
|
||
it('should create unloading arrow', () => { | ||
const unloadingArrow = VisualizationService.getContainerUnloadingArrow(containerWidth, containerLength); | ||
|
||
expect(unloadingArrow instanceof ArrowHelper).toBeTruthy(); | ||
}); | ||
|
||
const testSet = [ | ||
{ position: { height: 100, length: 100, width: 100, xCoord: 1, yCoord: 0, zCoord: 1 } as IPositionedElement & ISpace, parent: undefined as undefined | (IPositionedElement & ISpace), expected: { xCoord: 1, yCoord: 0, zCoord: 1 } as IPositionedElement }, | ||
{ position: { height: 100, length: 200, width: 100, xCoord: 1, yCoord: 0, zCoord: 1 } as IPositionedElement & ISpace, parent: { height: 1000, length: 1000, width: 1000, xCoord: 0, yCoord: 0, zCoord: 0 } as undefined | (IPositionedElement & ISpace), expected: { xCoord: -449, yCoord: -450, zCoord: -399 } as IPositionedElement }, | ||
{ position: { height: 100, length: Infinity, width: 100, xCoord: 1, yCoord: 0, zCoord: 1 } as IPositionedElement & ISpace, parent: { height: 1000, length: 1000, width: 1000, xCoord: 0, yCoord: 0, zCoord: 0 } as undefined | (IPositionedElement & ISpace), expected: { xCoord: -449, yCoord: -500 + (infinityReplacement/2), zCoord: -449 } as IPositionedElement } | ||
]; | ||
testSet.forEach(({ position, parent, expected }) => { | ||
it(`expect relative position for pos(x: ${position.xCoord}, y: ${position.yCoord}, z: ${position.zCoord} | h: ${position.height}, w: ${position.width}, l: ${position.length}) and par(x: ${parent?.xCoord}, y: ${parent?.yCoord}, z: ${parent?.zCoord} | h: ${parent?.height}, w: ${parent?.width}, l: ${parent?.length}) to be rpos(x: ${expected.xCoord}, y: ${expected.yCoord}, z: ${expected.zCoord})`, () => { | ||
const relativePosition = VisualizationService.calculateRelativePosition(position, parent); | ||
expect(relativePosition).toEqual(expected); | ||
|
||
const testSet = [ | ||
{ position: { height: 100, length: 100, width: 100, xCoord: 1, yCoord: 0, zCoord: 1 } as IPositionedElement & ISpace, parent: undefined as undefined | (IPositionedElement & ISpace), expected: { xCoord: 1, yCoord: 0, zCoord: 1 } as IPositionedElement }, | ||
{ position: { height: 100, length: 200, width: 100, xCoord: 1, yCoord: 0, zCoord: 1 } as IPositionedElement & ISpace, parent: { height: 1000, length: 1000, width: 1000, xCoord: 0, yCoord: 0, zCoord: 0 } as undefined | (IPositionedElement & ISpace), expected: { xCoord: -449, yCoord: -450, zCoord: -399 } as IPositionedElement }, | ||
{ position: { height: 100, length: Infinity, width: 100, xCoord: 1, yCoord: 0, zCoord: 1 } as IPositionedElement & ISpace, parent: { height: 1000, length: 1000, width: 1000, xCoord: 0, yCoord: 0, zCoord: 0 } as undefined | (IPositionedElement & ISpace), expected: { xCoord: -449, yCoord: -500 + (infinityReplacement / 2), zCoord: -449 } as IPositionedElement } | ||
]; | ||
testSet.forEach(({ position, parent, expected }) => { | ||
it(`expect relative position for pos(x: ${position.xCoord}, y: ${position.yCoord}, z: ${position.zCoord} | h: ${position.height}, w: ${position.width}, l: ${position.length}) and par(x: ${parent?.xCoord}, y: ${parent?.yCoord}, z: ${parent?.zCoord} | h: ${parent?.height}, w: ${parent?.width}, l: ${parent?.length}) to be rpos(x: ${expected.xCoord}, y: ${expected.yCoord}, z: ${expected.zCoord})`, () => { | ||
const relativePosition = VisualizationService.calculateRelativePosition(position, parent); | ||
expect(relativePosition).toEqual(expected); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters