-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8448377
commit c1eac47
Showing
2 changed files
with
74 additions
and
0 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
33 changes: 33 additions & 0 deletions
33
src/tests/unit/services/uml-element/remote-selectable/remote-selectable-service-test.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { getRealStore } from '../../../test-utils/test-utils'; | ||
import { UMLClass } from '../../../../../main/packages/uml-class-diagram/uml-class/uml-class'; | ||
import { RemoteSelectable } from '../../../../../main/services/uml-element/remote-selectable/remote-selection-repository'; | ||
|
||
|
||
describe('test redux state upon changing remote selection.', () => { | ||
test('elements can be selected.', () => { | ||
const classA = new UMLClass({ name: 'ClassA' }); | ||
const classB = new UMLClass({ name: 'ClassB' }); | ||
|
||
const john = { name: 'John', color: 'red' }; | ||
const jane = { name: 'Jane', color: 'blue' }; | ||
|
||
const store = getRealStore({}, [classA, classB]); | ||
|
||
expect(store.getState().remoteSelection).toEqual({}); | ||
|
||
store.dispatch(RemoteSelectable.remoteSelect(john, [classA.id])); | ||
expect(store.getState().remoteSelection).toEqual({ [classA.id]: [john] }); | ||
|
||
store.dispatch(RemoteSelectable.remoteSelect(jane, [classA.id, classB.id])); | ||
expect(store.getState().remoteSelection).toEqual({ [classA.id]: [john, jane], [classB.id]: [jane] }); | ||
|
||
store.dispatch(RemoteSelectable.remoteDeselect(jane, [classA.id])); | ||
expect(store.getState().remoteSelection).toEqual({ [classA.id]: [john], [classB.id]: [jane] }); | ||
|
||
store.dispatch(RemoteSelectable.remoteSelectDeselect(john, [classB.id], [classA.id])); | ||
expect(store.getState().remoteSelection).toEqual({ [classA.id]: [], [classB.id]: [jane, john] }); | ||
|
||
store.dispatch(RemoteSelectable.pruneRemoteSelectors([jane])); | ||
expect(store.getState().remoteSelection).toEqual({ [classA.id]: [], [classB.id]: [jane] }); | ||
}); | ||
}); |