{{!-- Endpoint Integration Test Template --}}
{{!-- Generated by @soapjs/integr8 --}}

{{#if imports}}
{{#each imports}}
import { {{this}} } from '{{@key}}';
{{/each}}
{{/if}}

{{> setup-teardown}}
describe('{{endpoint.method}} {{endpoint.path}}', () => {
  {{#if endpoint.testScenarios}}
  {{#each endpoint.testScenarios}}
  test('{{description}}', async () => {
    const ctx = getEnvironmentContext();
    
    {{#if requestData}}
    const requestData = {{json requestData}};
    {{else}}
    const requestData = {};
    {{/if}}
    {{#if queryParams}}
    const queryParams = {{json queryParams}};
    {{/if}}
    {{#if pathParams}}
    const pathParams = {{json pathParams}};
    {{/if}}
    
    {{#if (eq ../endpoint.method "GET")}}
    const response = await ctx.getHttp().{{lowercase ../endpoint.method}}('{{../endpoint.path}}'{{#if queryParams}}, { params: queryParams }{{/if}});
    {{/if}}
    {{#if (eq ../endpoint.method "POST")}}
    const response = await ctx.getHttp().{{lowercase ../endpoint.method}}('{{../endpoint.path}}', requestData);
    {{/if}}
    {{#if (eq ../endpoint.method "PUT")}}
    const response = await ctx.getHttp().{{lowercase ../endpoint.method}}('{{../endpoint.path}}', requestData);
    {{/if}}
    {{#if (eq ../endpoint.method "PATCH")}}
    const response = await ctx.getHttp().{{lowercase ../endpoint.method}}('{{../endpoint.path}}', requestData);
    {{/if}}
    {{#if (eq ../endpoint.method "DELETE")}}
    const response = await ctx.getHttp().{{lowercase ../endpoint.method}}('{{../endpoint.path}}');
    {{/if}}
    
    expect(response.status).toBe({{expectedStatus}});
    {{#if expectedResponse}}
    expect(response.data).toMatchObject({{json expectedResponse}});
    {{/if}}
  });
  {{/each}}
  {{/if}}
});
