text: 'use strict';
  
  const generate = require('./scripts/generate');
  const copy = require('./scripts/copy');
  const compileWithTypescript = require('./scripts/compileWithTypescript');
  const server = require('./scripts/server');
  const browser = require('./scripts/browser');
  
  describe('v3.xhr', () => {
  
      beforeAll(async () => {
          await generate('v3/xhr', 'v3', 'xhr');
          await copy('v3/xhr');
          compileWithTypescript('v3/xhr');
          await server.start('v3/xhr');
          await browser.start();
      }, 30000);
  
      afterAll(async () => {
          await browser.stop();
          await server.stop();
      });
  
      it('requests token', async () => {
          await browser.exposeFunction('tokenRequest', jest.fn().mockResolvedValue('MY_TOKEN'));
          const result = await browser.evaluate(async () => {
              const { OpenAPI, SimpleService } = window.api;
              OpenAPI.TOKEN = window.tokenRequest;
              OpenAPI.USERNAME = undefined;
              OpenAPI.PASSWORD = undefined;
              return await SimpleService.getCallWithoutParametersAndResponse();
          });
          expect(result.headers.authorization).toBe('Bearer MY_TOKEN');
      });
  
      it('uses credentials', async () => {
          const result = await browser.evaluate(async () => {
              const { OpenAPI, SimpleService } = window.api;
              OpenAPI.TOKEN = undefined;
              OpenAPI.USERNAME = 'username';
              OpenAPI.PASSWORD = 'password';
              return await SimpleService.getCallWithoutParametersAndResponse();
          });
          expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ=');
      });
  
      it('complexService', async () => {
          const result = await browser.evaluate(async () => {
              const { ComplexService } = window.api;
              return await ComplexService.complexTypes({
                  first: {
                      second: {
                          third: 'Hello World!'
                      }
                  }
              });
          });
          expect(result).toBeDefined();
      });
  });
  