<commit_before>describe("export_image_result_view", function() {
  beforeEach(function() {
    this.url = "http://www.cartodb.com";

    this.vis = new cdb.admin.Visualization({
      type: 'derived',
      name: '<NAME>'
    });

    this.view = new cdb.editor.ExportImageResultView({
      vis: this.vis,
      clean_on_hide: true,
      enter_to_confirm: false,
      user: TestUtil.createUser('jamon'),
      x: 0,
      y: 0,
      width: 100,
      height: 100
    });

    spyOn(this.view, '_loadMapImage').and.callFake(function(value, callback) {return callback(value);}); 
    spyOn(this.view, '_mergeAnnotations').and.returnValue("url")

    this.view.render();
  });

  afterEach(function() {
    this.view.clean();
  });

  it("should render the result view", function() {
    this.view.generateImage(this.url);
    expect(this.view.$(".js-open-image").length).toBe(1);
    expect(this.innerHTML()).toContain("Your image has been generated correctly");
    expect(this.innerHTML()).toContain('<p class="Dialog-headerText">It\'s now available in: <a href="http://www.cartodb.com" target="_blank" class="ExportImageResult--url">' + this.url + '</a></p>');
  });

  it("should close the dialog when clicking on the view image link", function() {
    this.view.generateImage(this.url);
    var hidden = false;
    this.view.bind("hide", function() {
      hidden = true;
    });
    this.view.$(".js-open-image").click();
    expect(hidden).toBe(true);
  });

  it("should trigger a finish event", function() {
    var finish = false;
    this.view.bind("finish", function() {
      finish = true;
    });
    this.view.generateImage(this.url);
    expect(finish).toBe(true);
  });

  it("should generate exported image filename correctly", function() {
    var filename = this.view._generateImageFilename();

    expect(filename).toMatch(/^[\S]+_by_[\S]+_\d\d_\d\d_\d\d\d\d_\d\d_\d\d_\d\d$/)
  });

});<commit_msg>Adds check for displayed link<commit_after>describe("export_image_result_view", function() {

  beforeEach(function() {
    this.filenameRegexp = '[\\S]+_by_[\\S]+_\\d\\d_\\d\\d_\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d'
    this.url = "http://www.cartodb.com";

    this.vis = new cdb.admin.Visualization({
      type: 'derived',
      name: '<NAME>'
    });

    this.view = new cdb.editor.ExportImageResultView({
      vis: this.vis,
      clean_on_hide: true,
      enter_to_confirm: false,
      user: TestUtil.createUser('jamon'),
      x: 0,
      y: 0,
      width: 100,
      height: 100
    });

    spyOn(this.view, '_loadMapImage').and.callFake(function(value, callback) {return callback(value);}); 
    spyOn(this.view, '_mergeAnnotations').and.returnValue("url")

    this.view.render();
  });

  afterEach(function() {
    this.view.clean();
  });

  it("should render the result view", function() {
    this.view.generateImage(this.url);
    expect(this.view.$(".js-open-image").length).toBe(1);
    expect(this.innerHTML()).toContain("Your image has been generated correctly");
    expect(this.view.$('p.Dialog-headerText').html()).toMatch('It\'s now available in: <a href="' + this.url + '" target="_blank" class="ExportImageResult--url" download="' + this.filenameRegexp + '">' + this.url.substring(0, 255) + '</a>');
  });

  it("should close the dialog when clicking on the view image link", function() {
    this.view.generateImage(this.url);
    var hidden = false;
    this.view.bind("hide", function() {
      hidden = true;
    });
    this.view.$(".js-open-image").click();
    expect(hidden).toBe(true);
  });

  it("should trigger a finish event", function() {
    var finish = false;
    this.view.bind("finish", function() {
      finish = true;
    });
    this.view.generateImage(this.url);
    expect(finish).toBe(true);
  });

  it("should generate exported image filename correctly", function() {
    var filename = this.view._generateImageFilename();

    expect(filename).toMatch(this.filenameRegexp)
  });

});
{'fraction_non_alphanumeric': 0.1869323915237134, 'fraction_numerical': 0.005549949545913219, 'mean_word_length': 3.295774647887324, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5937592', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1274, 'n_words': 237}