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

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

Open
G0ldenSp00n-zz opened this issue Oct 14, 2018 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@G0ldenSp00n-zz
Copy link
Collaborator

G0ldenSp00n-zz commented Oct 14, 2018

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'});
    });
@G0ldenSp00n-zz G0ldenSp00n-zz added the bug Something isn't working label Oct 14, 2018
@G0ldenSp00n-zz G0ldenSp00n-zz changed the title Getting State of Nodes with Nested Arrays Don't Return Formatted Array Getting State of Nodes with Nested Collections Don't Return Formatted Array Oct 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants