Skip to content

Commit

Permalink
fix: hooks not cloned in loop
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua-ola authored and AnWeber committed Mar 23, 2023
1 parent e2c9766 commit 7b8afd6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/store/httpRegion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class HttpRegion implements models.HttpRegion {
const httpRegion = new HttpRegion(this.httpFile);
httpRegion.request = this.request;
Object.assign(httpRegion.symbol, this.symbol);
Object.assign(httpRegion.hooks, this.symbol);
Object.assign(httpRegion.hooks, this.hooks);
Object.assign(httpRegion.variablesPerEnv, this.variablesPerEnv);
Object.assign(httpRegion.metaData, this.metaData);
return httpRegion;
Expand Down
43 changes: 43 additions & 0 deletions src/test/request/graphql.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,49 @@ query launchesQuery($limit: Int!){
}
}
{{ variables }}
`);

const requests = await mockedEndpoints.getSeenRequests();
expect(requests[0].url).toBe('http://localhost:7002/graphql');
expect(await requests[0].body.getText()).toBe(
'{"query":"query launchesQuery($limit: Int!){\\n launchesPast(limit: $limit) {\\n mission_name\\n launch_date_local\\n launch_site {\\n site_name_long\\n }\\n rocket {\\n rocket_name\\n rocket_type\\n }\\n ships {\\n name\\n home_port\\n image\\n }\\n }\\n}","operationName":"launchesQuery","variables":{"limit":10}}'
);
});

it('query + operation + loop', async () => {
initFileProvider();
const mockedEndpoints = await localServer.forPost('/graphql').thenReply(200);

await sendHttp(`
{{
exports.variables = {
"limit": 10
};
}}
# @loop for 1
POST http://localhost:7002/graphql
query launchesQuery($limit: Int!){
launchesPast(limit: $limit) {
mission_name
launch_date_local
launch_site {
site_name_long
}
rocket {
rocket_name
rocket_type
}
ships {
name
home_port
image
}
}
}
{{ variables }}
`);

Expand Down

0 comments on commit 7b8afd6

Please sign in to comment.