/* globals expect, it, describe, PDFJS, isExternalLinkTargetSet, LinkTarget,
           getFilenameFromUrl */

'use strict';

describe('dom_utils', function() {
  describe('getFilenameFromUrl', function() {
    it('should get the filename from an absolute URL', function() {
      var url = 'http://server.org/filename.pdf';
      var result = getFilenameFromUrl(url);
      var expected = 'filename.pdf';
      expect(result).toEqual(expected);
    });

    it('should get the filename from a relative URL', function() {
      var url = '../../filename.pdf';
      var result = getFilenameFromUrl(url);
      var expected = 'filename.pdf';
      expect(result).toEqual(expected);
    });
  });

  describe('isExternalLinkTargetSet', function() {
    // Save the current state, to avoid interfering with other tests.
    var previousExternalLinkTarget = PDFJS.externalLinkTarget;

    it('handles the predefined LinkTargets', function() {
      for (var key in LinkTarget) {
        var linkTarget = LinkTarget[key];
        PDFJS.externalLinkTarget = linkTarget;

        expect(isExternalLinkTargetSet()).toEqual(!!linkTarget);
      }
    });

    it('handles incorrect LinkTargets', function() {
      var targets = [true, '', false, -1, '_blank', null];

      for (var i = 0, ii = targets.length; i < ii; i++) {
        var linkTarget = targets[i];
        PDFJS.externalLinkTarget = linkTarget;

        expect(isExternalLinkTargetSet()).toEqual(false);
      }
    });

    // Reset the state.
    PDFJS.externalLinkTarget = previousExternalLinkTarget;
  });
});

@@ -103,12 +103,33 @@
 mUrl
+, beforeAll, afterAll
  */%0A
-
 %0A'us
@@ -769,91 +769,191 @@
     
-// Save the current state, to avoid interfering with other tests.%0A    var previousE
+var savedExternalLinkTarget;%0A%0A    beforeAll(function (done) %7B%0A      savedExternalLinkTarget = PDFJS.externalLinkTarget;%0A      done();%0A    %7D);%0A%0A    afterAll(function () %7B%0A      PDFJS.e
 xter
@@ -960,39 +960,38 @@
 nalLinkTarget = 
-PDFJS.e
+savedE
 xternalLinkTarge
@@ -988,24 +988,32 @@
 lLinkTarget;
+%0A    %7D);
 %0A%0A    it('ha
@@ -1594,99 +1594,15 @@
   %7D%0A
+
     %7D);
-%0A%0A    // Reset the state.%0A    PDFJS.externalLinkTarget = previousExternalLinkTarget;
 %0A  %7D

Use `beforeAll`/`afterAll` in `isExternalLinkTargetSet` in dom_utils_spec.js (issue 6905)