import { whenRequest } from '@wix/fe-essentials/http-client/testkit/client';
import {
  createExportAsyncJob,
  getExportAsyncJob,
} from '@wix/bex-utils/@wix/ambassador-fedinfra-exportservice-v1-export-async-job/http';

let resultsDelayCounter = 0;
export const exportMocks = [
  whenRequest(createExportAsyncJob)
    .reply(200, {
      __applicationErrorsType: {},
      job: { id: 'XXX' },
    })
    .persist(),
  whenRequest(getExportAsyncJob)
    .reply(200, () => {
      if (resultsDelayCounter < 5) {
        resultsDelayCounter++;
        return {
          __applicationErrorsType: {},
          job: {
            id: 'XXX',
            data: {
              pagingMetadata: {
                offset: 20 * resultsDelayCounter,
              },
            },
          },
        };
      }
      resultsDelayCounter = 0;
      return {
        __applicationErrorsType: {},
        job: {
          id: 'XXX',
          data: {
            pagingMetadata: {
              offset: 10,
            },
            signedUrl: './export.csv',
          },
        },
      };
    })
    .persist(),
];
