mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 16:25:21 +00:00
Fixed FieldsArray.push to preserve the order of input items
This commit is contained in:
@@ -40,6 +40,15 @@ describe("FieldsArray", () => {
|
|||||||
expect(fa[0]).toEqual({ key: "t1", value: "v1" });
|
expect(fa[0]).toEqual({ key: "t1", value: "v1" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should preserve order of input items when adding fields", () => {
|
||||||
|
expect(
|
||||||
|
fa.push({ key: "t1", value: "v1" }, { key: "t2", value: "v2" })
|
||||||
|
).toBe(2);
|
||||||
|
expect(fa.length).toBe(2);
|
||||||
|
expect(fa[0]).toEqual({ key: "t1", value: "v1" });
|
||||||
|
expect(fa[1]).toEqual({ key: "t2", value: "v2" });
|
||||||
|
});
|
||||||
|
|
||||||
it("should add the key to the pool", () => {
|
it("should add the key to the pool", () => {
|
||||||
fa.push({ key: "t1", value: "v1" });
|
fa.push({ key: "t1", value: "v1" });
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ function registerWithValidation(
|
|||||||
|
|
||||||
let validItems: Schemas.Field[] = [];
|
let validItems: Schemas.Field[] = [];
|
||||||
|
|
||||||
for (let i = items.length, field: Schemas.Field; (field = items[--i]); ) {
|
for (const field of items) {
|
||||||
try {
|
try {
|
||||||
Schemas.assertValidity(
|
Schemas.assertValidity(
|
||||||
Schemas.Field,
|
Schemas.Field,
|
||||||
|
|||||||
Reference in New Issue
Block a user