Skip to content

Getting State of Nodes with Nested Collections Don't Return Formatted Array #56

@G0ldenSp00n-zz

Description

@G0ldenSp00n-zz

Describe the bug
Getting the State on a Container Node with nested state containing an array, or object returns an array or object of VirtualNodes, rather than the formatted object. Rather, it should return an array of the primitive values only, not VirutalNodes

To Reproduce
Steps to reproduce the behavior:

  1. Create A ConstructorNode, and Initialize the State with an Array Populated with Values
  2. CombineNodes with the ConstructorNode
  3. Called Get State on the SiloNode returned by combineNodes
  4. Notice that the array is returned as a set of virtual nodes rather than an array of values

Expected behavior
If I initialize state with an array, [1, 2] the array returned when calling get state should consist of [1, 2] rather than the current returned value of [VirtualNode {val: 1 ...}, VirtualNode {val: 2 ...}]. This should be true of all values in VirtualNodes that are not ContainerNodes.

Test Snippet

test('State Is Correctly Initialized', () => {
        let rootNode = new constructorNode('Root');

        rootNode.initializeState({
            testString: 'Testing',
            testNum: 123,
            testArr: ['1', '2', '3'],
            testObject: {
                key1: '1',
                key2: '2',
                key3: '3'
            }
        });

        let generatedTree = combineNodes(rootNode);

        expect(generatedTree.Root.getState().testString.val).toBe('Testing');
        expect(generatedTree.Root.getState().testNum.val).toBe(123);
        console.warn('State Is Correctly Initialized: Removed Due to Bug #56 - https://github.com/radonjs/Radon/issues/56');
        //Removed Due to Bug #56 - https://github.com/radonjs/Radon/issues/56
        //expect(generatedTree.Root.getState().testArr).toEqual(['1', '2', '3']);
        //expect(generatedTree.Root.getState().testObject).toEqual({key1: '1', key2: '2', key3: '3'});
    });

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions