Skip to content

Commit

Permalink
fix: createReq inconsistent on array
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed Jun 18, 2021
1 parent 3f98b98 commit 68865ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/createReq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function createValue(paths: string[], ctx: VmContext, jsa: JsonaValue) {
_.set(ctx.state, paths, _.get(ctx.state, paths, []));
const output = _.get(ctx.state, paths);
for (const [i, ele] of jsa.elements.entries()) {
output.push(await createValue(paths.concat([String(i)]), ctx, ele));
output[i] = await createValue(paths.concat([String(i)]), ctx, ele);
}
result = output;
} else if (jsa.type === "Object") {
Expand Down
18 changes: 13 additions & 5 deletions tests/fixtures/res/every.jsona
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@
@client({name:"default",kind:"echo"})
test1: { @describe("@every")
req: {
v1: "integer(1, 10)", @mock
arr: [
{name: "v1"},
{name: "v2"},
{name: "v3"},
]
},
res: {
v1: [ @every
"$ > -1", @eval
"$ > 0", @eval
]
arr: [ @every
[ @partial
{
name: "", @type
}
],
`$.length === 3`, @eval
],
}
},
test2: { @describe("fail# @every")
Expand Down

0 comments on commit 68865ab

Please sign in to comment.