summaryrefslogtreecommitdiff
path: root/tests/frontend/specs/urls_become_clickable.js
blob: 8c72d748eeea809b9c60cc4aee907e7ec3b4021a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
describe("urls", function(){
  //create a new pad before each test run
  beforeEach(function(cb){
    helper.newPad(cb);
    this.timeout(60000);
  });

  it("when you enter an url, it becomes clickable", function(done) {
    var inner$ = helper.padInner$; 
    var chrome$ = helper.padChrome$; 
    
    //get the first text element out of the inner iframe
    var firstTextElement = inner$("div").first();
    
    // simulate key presses to delete content
    firstTextElement.sendkeys('{selectall}'); // select all
    firstTextElement.sendkeys('{del}'); // clear the first line
    firstTextElement.sendkeys('http://etherpad.org'); // insert a URL
	  
    helper.waitFor(function(){
      return inner$("div").first().find("a").length === 1;
    }, 2000).done(done);
  });

  it("when you enter a url containing a !, it becomes clickable and contains the whole URL", function(done) {
    var inner$ = helper.padInner$;
    var chrome$ = helper.padChrome$;

    //get the first text element out of the inner iframe
    var firstTextElement = inner$("div").first();
    var url = "http://etherpad.org/!foo";

    // simulate key presses to delete content
    firstTextElement.sendkeys('{selectall}'); // select all
    firstTextElement.sendkeys('{del}'); // clear the first line
    firstTextElement.sendkeys(url); // insert a URL

    helper.waitFor(function(){
      if(inner$("div").first().find("a").length === 1){ // if it contains an A link
        if(inner$("div").first().find("a")[0].href === url){
          return true;
        }
      };
    }, 2000).done(done);
  });

});