Skip to content

[Bug]: ArraySchema: consecutive .unshift() calls are not encoded properly #193

Open
@endel

Description

@endel

The following test case is not passing:

class State extends Schema {
    @type(["number"]) arrayOfNumbers = new ArraySchema<number>();
}

const state = new State();
state.arrayOfNumbers.push(1);
state.arrayOfNumbers.push(2);
state.arrayOfNumbers.push(3);

const decodedState = new State();
decodedState.decode(state.encode());

// HERE: consecutive unshift calls aren't encoded properly.
state.arrayOfNumbers.unshift(0);
state.arrayOfNumbers.unshift(-1);
assert.strictEqual(-1, state.arrayOfNumbers[0]);

decodedState.decode(state.encode());
assert.deepStrictEqual([-1, 0, 1, 2, 3], decodedState.arrayOfNumbers.toJSON()); // FAILS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions