text: import RmpVast from '../../../../js/src/index.js';
  
  const ADTAG1 = 'https://www.radiantmediaplayer.com/vast/tags/inline-linear-1.xml';
  const ADTAG2 = 'https://www.radiantmediaplayer.com/vast/tags/inline-linear-error.xml';
  const ADTAG3 = 'https://www.radiantmediaplayer.com/vast/tags/inline-linear-1.xml';
  
  describe('Test for ThreeConsecutiveWithErrorLinearSpec', function () {
  
    const id = 'rmpPlayer';
    const container = document.getElementById(id);
    const video = document.querySelector('.rmp-video');
    const rmpVast = new RmpVast(id);
    const env = rmpVast.getEnvironment();
    video.muted = true;
    if (env.isAndroid[0]) {
      container.style.width = '320px';
      container.style.height = '180px';
    }
  
    const title = document.getElementsByTagName('title')[0];
  
    it('should load 3 consecutive adTag and play them', function (done) {
      let validSteps = 0;
  
      const _incrementAndLog = function (event) {
        validSteps++;
        if (event && event.type) {
          console.log(event.type);
        }
      };
  
      container.addEventListener('adloaded', function (e) {
        _incrementAndLog(e);
      });
      container.addEventListener('adstarted', function (e) {
        _incrementAndLog(e);
      });
      container.addEventListener('addurationchange', function (e) {
        _incrementAndLog(e);
      });
      container.addEventListener('adimpression', function (e) {
        _incrementAndLog(e);
      });
      container.addEventListener('adtagstartloading', function (e) {
        _incrementAndLog(e);
      });
      container.addEventListener('adtagloaded', function (e) {
        _incrementAndLog(e);
      });
      container.addEventListener('adcomplete', function (e) {
        _incrementAndLog(e);
      });
      container.addEventListener('adfirstquartile', function (e) {
        _incrementAndLog(e);
      });
      container.addEventListener('admidpoint', function (e) {
        _incrementAndLog(e);
      });
      container.addEventListener('adthirdquartile', function (e) {
        _incrementAndLog(e);
      });
      container.addEventListener('aderror', function (e) {
        _incrementAndLog(e);
      });
      let addestroyedCount = 0;
      container.addEventListener('addestroyed', function (e) {
        _incrementAndLog(e);
        addestroyedCount++;
        if (addestroyedCount === 1) {
          expect(validSteps).toBe(11);
          rmpVast.loadAds(ADTAG2);
        }
        if (addestroyedCount === 2) {
          expect(validSteps).toBe(14);
          rmpVast.loadAds(ADTAG3);
        }
        if (addestroyedCount === 3) {
          let timeupdateCount = 0;
          video.addEventListener('timeupdate', function (e) {
            timeupdateCount++;
            if (timeupdateCount === 5) {
              _incrementAndLog(e);
              if (validSteps === 26) {
                expect(validSteps).toBe(26);
                title.textContent = 'Test completed';
                done();
              }
            }
          });
        }
      });
  
      rmpVast.loadAds(ADTAG1);
    });
  
  
  });
  